Created
November 21, 2016 09:46
-
-
Save darfink/d519756ad88efcddfbfe895439cf9451 to your computer and use it in GitHub Desktop.
Example binding generated from ChakraCore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// automatically generated by rust-bindgen | |
pub type ChakraCookie = usize; | |
pub type ChakraBytePtr = *mut libc::c_uchar; | |
pub type BYTE = libc::c_uchar; | |
pub type byte = BYTE; | |
#[repr(u32)] | |
/// <summary> | |
/// An error code returned from a Chakra hosting API. | |
/// </summary> | |
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | |
pub enum JsErrorCode { | |
NoError = 0, | |
CategoryUsage = 65536, | |
InvalidArgument = 65537, | |
NullArgument = 65538, | |
NoCurrentContext = 65539, | |
InExceptionState = 65540, | |
NotImplemented = 65541, | |
WrongThread = 65542, | |
RuntimeInUse = 65543, | |
BadSerializedScript = 65544, | |
InDisabledState = 65545, | |
CannotDisableExecution = 65546, | |
HeapEnumInProgress = 65547, | |
ArgumentNotObject = 65548, | |
InProfileCallback = 65549, | |
InThreadServiceCallback = 65550, | |
CannotSerializeDebugScript = 65551, | |
AlreadyDebuggingContext = 65552, | |
AlreadyProfilingContext = 65553, | |
IdleNotEnabled = 65554, | |
CannotSetProjectionEnqueueCallback = 65555, | |
CannotStartProjection = 65556, | |
InObjectBeforeCollectCallback = 65557, | |
ObjectNotInspectable = 65558, | |
PropertyNotSymbol = 65559, | |
PropertyNotString = 65560, | |
InvalidContext = 65561, | |
InvalidModuleHostInfoKind = 65562, | |
ModuleParsed = 65563, | |
ModuleEvaluated = 65564, | |
CategoryEngine = 131072, | |
OutOfMemory = 131073, | |
BadFPUState = 131074, | |
CategoryScript = 196608, | |
ScriptException = 196609, | |
ScriptCompile = 196610, | |
ScriptTerminated = 196611, | |
ScriptEvalDisabled = 196612, | |
CategoryFatal = 262144, | |
Fatal = 262145, | |
WrongRuntime = 262146, | |
CategoryDiagError = 327680, | |
DiagAlreadyInDebugMode = 327681, | |
DiagNotInDebugMode = 327682, | |
DiagNotAtBreak = 327683, | |
DiagInvalidHandle = 327684, | |
DiagObjectNotFound = 327685, | |
DiagUnableToPerformAction = 327686, | |
} | |
/// <summary> | |
/// A handle to a Chakra runtime. | |
/// </summary> | |
/// <remarks> | |
/// <para> | |
/// Each Chakra runtime has its own independent execution engine, JIT compiler, and garbage | |
/// collected heap. As such, each runtime is completely isolated from other runtimes. | |
/// </para> | |
/// <para> | |
/// Runtimes can be used on any thread, but only one thread can call into a runtime at any | |
/// time. | |
/// </para> | |
/// <para> | |
/// NOTE: A <c>JsRuntimeHandle</c>, unlike other object references in the Chakra hosting API, | |
/// is not garbage collected since it contains the garbage collected heap itself. A runtime | |
/// will continue to exist until <c>JsDisposeRuntime</c> is called. | |
/// </para> | |
/// </remarks> | |
#[repr(C)] | |
#[derive(Copy, Clone, Debug)] | |
pub struct JsRuntimeHandle(pub *mut libc::c_void); | |
impl JsRuntimeHandle { | |
pub fn new() -> Self { | |
JsRuntimeHandle(::std::ptr::null_mut()) | |
} | |
} | |
/// <summary> | |
/// A reference to an object owned by the Chakra garbage collector. | |
/// </summary> | |
/// <remarks> | |
/// A Chakra runtime will automatically track <c>JsRef</c> references as long as they are | |
/// stored in local variables or in parameters (i.e. on the stack). Storing a <c>JsRef</c> | |
/// somewhere other than on the stack requires calling <c>JsAddRef</c> and <c>JsRelease</c> to | |
/// manage the lifetime of the object, otherwise the garbage collector may free the object | |
/// while it is still in use. | |
/// </remarks> | |
#[repr(C)] | |
#[derive(Copy, Clone, Debug)] | |
pub struct JsRef(pub *mut libc::c_void); | |
impl JsRef { | |
pub fn new() -> Self { | |
JsRef(::std::ptr::null_mut()) | |
} | |
} | |
/// <summary> | |
/// A reference to a script context. | |
/// </summary> | |
/// <remarks> | |
/// <para> | |
/// Each script context contains its own global object, distinct from the global object in | |
/// other script contexts. | |
/// </para> | |
/// <para> | |
/// Many Chakra hosting APIs require an "active" script context, which can be set using | |
/// <c>JsSetCurrentContext</c>. Chakra hosting APIs that require a current context to be set | |
/// will note that explicitly in their documentation. | |
/// </para> | |
/// </remarks> | |
pub type JsContextRef = JsRef; | |
/// <summary> | |
/// A reference to a JavaScript value. | |
/// </summary> | |
/// <remarks> | |
/// A JavaScript value is one of the following types of values: undefined, null, Boolean, | |
/// string, number, or object. | |
/// </remarks> | |
pub type JsValueRef = JsRef; | |
/// <summary> | |
/// A cookie that identifies a script for debugging purposes. | |
/// </summary> | |
pub type JsSourceContext = ChakraCookie; | |
/// <summary> | |
/// A property identifier. | |
/// </summary> | |
/// <remarks> | |
/// Property identifiers are used to refer to properties of JavaScript objects instead of using | |
/// strings. | |
/// </remarks> | |
pub type JsPropertyIdRef = JsRef; | |
pub const JsRuntimeAttributeNone: JsRuntimeAttributes = JsRuntimeAttributes(0); | |
pub const JsRuntimeAttributeDisableBackgroundWork: JsRuntimeAttributes = JsRuntimeAttributes(1); | |
pub const JsRuntimeAttributeAllowScriptInterrupt: JsRuntimeAttributes = JsRuntimeAttributes(2); | |
pub const JsRuntimeAttributeEnableIdleProcessing: JsRuntimeAttributes = JsRuntimeAttributes(4); | |
pub const JsRuntimeAttributeDisableNativeCodeGeneration: JsRuntimeAttributes = | |
JsRuntimeAttributes(8); | |
pub const JsRuntimeAttributeDisableEval: JsRuntimeAttributes = JsRuntimeAttributes(16); | |
pub const JsRuntimeAttributeEnableExperimentalFeatures: JsRuntimeAttributes = | |
JsRuntimeAttributes(32); | |
pub const JsRuntimeAttributeDispatchSetExceptionsToDebugger: JsRuntimeAttributes = | |
JsRuntimeAttributes(64); | |
impl ::std::ops::BitOr<JsRuntimeAttributes> for JsRuntimeAttributes { | |
type Output = Self; | |
#[inline] | |
fn bitor(self, other: Self) -> Self { | |
JsRuntimeAttributes(self.0 | other.0) | |
} | |
} | |
#[repr(C)] | |
/// <summary> | |
/// Attributes of a runtime. | |
/// </summary> | |
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | |
pub struct JsRuntimeAttributes(pub u32); | |
#[repr(u32)] | |
/// <summary> | |
/// The type of a typed JavaScript array. | |
/// </summary> | |
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | |
pub enum JsTypedArrayType { | |
Int8 = 0, | |
Uint8 = 1, | |
Uint8Clamped = 2, | |
Int16 = 3, | |
Uint16 = 4, | |
Int32 = 5, | |
Uint32 = 6, | |
Float32 = 7, | |
Float64 = 8, | |
} | |
#[repr(u32)] | |
/// <summary> | |
/// Allocation callback event type. | |
/// </summary> | |
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | |
pub enum JsMemoryEventType { | |
Allocate = 0, | |
Free = 1, | |
Failure = 2, | |
} | |
pub const JsParseScriptAttributeNone: JsParseScriptAttributes = JsParseScriptAttributes(0); | |
pub const JsParseScriptAttributeLibraryCode: JsParseScriptAttributes = JsParseScriptAttributes(1); | |
pub const JsParseScriptAttributeArrayBufferIsUtf16Encoded: JsParseScriptAttributes = | |
JsParseScriptAttributes(2); | |
impl ::std::ops::BitOr<JsParseScriptAttributes> for JsParseScriptAttributes { | |
type Output = Self; | |
#[inline] | |
fn bitor(self, other: Self) -> Self { | |
JsParseScriptAttributes(self.0 | other.0) | |
} | |
} | |
#[repr(C)] | |
/// <summary> | |
/// Attribute mask for JsParseScriptWithAttributes | |
/// </summary> | |
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | |
pub struct JsParseScriptAttributes(pub u32); | |
#[repr(u32)] | |
/// <summary> | |
/// Type enumeration of a JavaScript property | |
/// </summary> | |
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | |
pub enum JsPropertyIdType { | |
String = 0, | |
Symbol = 1, | |
} | |
#[repr(u32)] | |
/// <summary> | |
/// The JavaScript type of a JsValueRef. | |
/// </summary> | |
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | |
pub enum JsValueType { | |
Undefined = 0, | |
Null = 1, | |
Number = 2, | |
String = 3, | |
Boolean = 4, | |
Object = 5, | |
Function = 6, | |
Error = 7, | |
Array = 8, | |
Symbol = 9, | |
ArrayBuffer = 10, | |
TypedArray = 11, | |
DataView = 12, | |
} | |
/// <summary> | |
/// User implemented callback routine for memory allocation events | |
/// </summary> | |
/// <remarks> | |
/// Use <c>JsSetRuntimeMemoryAllocationCallback</c> to register this callback. | |
/// </remarks> | |
/// <param name="callbackState"> | |
/// The state passed to <c>JsSetRuntimeMemoryAllocationCallback</c>. | |
/// </param> | |
/// <param name="allocationEvent">The type of type allocation event.</param> | |
/// <param name="allocationSize">The size of the allocation.</param> | |
/// <returns> | |
/// For the <c>JsMemoryAllocate</c> event, returning <c>true</c> allows the runtime to continue | |
/// with the allocation. Returning false indicates the allocation request is rejected. The | |
/// return value is ignored for other allocation events. | |
/// </returns> | |
pub type JsMemoryAllocationCallback = | |
::std::option::Option<unsafe extern "system" fn(callbackState: *mut libc::c_void, | |
allocationEvent: JsMemoryEventType, | |
allocationSize: usize) | |
-> bool>; | |
/// <summary> | |
/// A callback called before collection. | |
/// </summary> | |
/// <remarks> | |
/// Use <c>JsSetBeforeCollectCallback</c> to register this callback. | |
/// </remarks> | |
/// <param name="callbackState">The state passed to <c>JsSetBeforeCollectCallback</c>.</param> | |
pub type JsBeforeCollectCallback = | |
::std::option::Option<unsafe extern "system" fn(callbackState: *mut libc::c_void)>; | |
/// <summary> | |
/// A callback called before collecting an object. | |
/// </summary> | |
/// <remarks> | |
/// Use <c>JsSetObjectBeforeCollectCallback</c> to register this callback. | |
/// </remarks> | |
/// <param name="ref">The object to be collected.</param> | |
/// <param name="callbackState">The state passed to <c>JsSetObjectBeforeCollectCallback</c>.</param> | |
pub type JsObjectBeforeCollectCallback = | |
::std::option::Option<unsafe extern "system" fn(ref_: JsRef, | |
callbackState: *mut libc::c_void)>; | |
/// <summary> | |
/// A background work item callback. | |
/// </summary> | |
/// <remarks> | |
/// This is passed to the host's thread service (if provided) to allow the host to | |
/// invoke the work item callback on the background thread of its choice. | |
/// </remarks> | |
/// <param name="callbackState">Data argument passed to the thread service.</param> | |
pub type JsBackgroundWorkItemCallback = | |
::std::option::Option<unsafe extern "system" fn(callbackState: *mut libc::c_void)>; | |
/// <summary> | |
/// A thread service callback. | |
/// </summary> | |
/// <remarks> | |
/// The host can specify a background thread service when calling <c>JsCreateRuntime</c>. If | |
/// specified, then background work items will be passed to the host using this callback. The | |
/// host is expected to either begin executing the background work item immediately and return | |
/// true or return false and the runtime will handle the work item in-thread. | |
/// </remarks> | |
/// <param name="callback">The callback for the background work item.</param> | |
/// <param name="callbackState">The data argument to be passed to the callback.</param> | |
pub type JsThreadServiceCallback = | |
::std::option::Option<unsafe extern "system" fn(callback: JsBackgroundWorkItemCallback, | |
callbackState: *mut libc::c_void) | |
-> bool>; | |
/// <summary> | |
/// Called by the runtime when it is finished with all resources related to the script execution. | |
/// The caller should free the source if loaded, the byte code, and the context at this time. | |
/// </summary> | |
/// <param name="sourceContext">The context passed to Js[Parse|Run]SerializedScriptWithCallback</param> | |
pub type JsSerializedScriptUnloadCallback = | |
::std::option::Option<unsafe extern "system" fn(sourceContext: JsSourceContext)>; | |
/// <summary> | |
/// A finalizer callback. | |
/// </summary> | |
/// <param name="data"> | |
/// The external data that was passed in when creating the object being finalized. | |
/// </param> | |
pub type JsFinalizeCallback = | |
::std::option::Option<unsafe extern "system" fn(data: *mut libc::c_void)>; | |
/// <summary> | |
/// A function callback. | |
/// </summary> | |
/// <param name="callee"> | |
/// A function object that represents the function being invoked. | |
/// </param> | |
/// <param name="isConstructCall">Indicates whether this is a regular call or a 'new' call.</param> | |
/// <param name="arguments">The arguments to the call.</param> | |
/// <param name="argumentCount">The number of arguments.</param> | |
/// <param name="callbackState"> | |
/// The state passed to <c>JsCreateFunction</c>. | |
/// </param> | |
/// <returns>The result of the call, if any.</returns> | |
pub type JsNativeFunction = | |
::std::option::Option<unsafe extern "system" fn(callee: JsValueRef, | |
isConstructCall: bool, | |
arguments: *mut JsValueRef, | |
argumentCount: libc::c_ushort, | |
callbackState: *mut libc::c_void) | |
-> *mut libc::c_void>; | |
/// <summary> | |
/// A promise continuation callback. | |
/// </summary> | |
/// <remarks> | |
/// The host can specify a promise continuation callback in <c>JsSetPromiseContinuationCallback</c>. If | |
/// a script creates a task to be run later, then the promise continuation callback will be called with | |
/// the task and the task should be put in a FIFO queue, to be run when the current script is | |
/// done executing. | |
/// </remarks> | |
/// <param name="task">The task, represented as a JavaScript function.</param> | |
/// <param name="callbackState">The data argument to be passed to the callback.</param> | |
pub type JsPromiseContinuationCallback = | |
::std::option::Option<unsafe extern "system" fn(task: JsValueRef, | |
callbackState: *mut libc::c_void)>; | |
extern "system" { | |
/// <summary> | |
/// Creates a new runtime. | |
/// </summary> | |
/// <param name="attributes">The attributes of the runtime to be created.</param> | |
/// <param name="threadService">The thread service for the runtime. Can be null.</param> | |
/// <param name="runtime">The runtime created.</param> | |
/// <remarks>In the edge-mode binary, chakra.dll, this function lacks the <c>runtimeVersion</c> | |
/// parameter (compare to jsrt9.h).</remarks> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsCreateRuntime(attributes: JsRuntimeAttributes, | |
threadService: JsThreadServiceCallback, | |
runtime: *mut JsRuntimeHandle) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Performs a full garbage collection. | |
/// </summary> | |
/// <param name="runtime">The runtime in which the garbage collection will be performed.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsCollectGarbage(runtime: JsRuntimeHandle) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Disposes a runtime. | |
/// </summary> | |
/// <remarks> | |
/// Once a runtime has been disposed, all resources owned by it are invalid and cannot be used. | |
/// If the runtime is active (i.e. it is set to be current on a particular thread), it cannot | |
/// be disposed. | |
/// </remarks> | |
/// <param name="runtime">The runtime to dispose.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsDisposeRuntime(runtime: JsRuntimeHandle) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Gets the current memory usage for a runtime. | |
/// </summary> | |
/// <remarks> | |
/// Memory usage can be always be retrieved, regardless of whether or not the runtime is active | |
/// on another thread. | |
/// </remarks> | |
/// <param name="runtime">The runtime whose memory usage is to be retrieved.</param> | |
/// <param name="memoryUsage">The runtime's current memory usage, in bytes.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsGetRuntimeMemoryUsage(runtime: JsRuntimeHandle, | |
memoryUsage: *mut usize) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Gets the current memory limit for a runtime. | |
/// </summary> | |
/// <remarks> | |
/// The memory limit of a runtime can be always be retrieved, regardless of whether or not the | |
/// runtime is active on another thread. | |
/// </remarks> | |
/// <param name="runtime">The runtime whose memory limit is to be retrieved.</param> | |
/// <param name="memoryLimit"> | |
/// The runtime's current memory limit, in bytes, or -1 if no limit has been set. | |
/// </param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsGetRuntimeMemoryLimit(runtime: JsRuntimeHandle, | |
memoryLimit: *mut usize) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Sets the current memory limit for a runtime. | |
/// </summary> | |
/// <remarks> | |
/// <para> | |
/// A memory limit will cause any operation which exceeds the limit to fail with an "out of | |
/// memory" error. Setting a runtime's memory limit to -1 means that the runtime has no memory | |
/// limit. New runtimes default to having no memory limit. If the new memory limit exceeds | |
/// current usage, the call will succeed and any future allocations in this runtime will fail | |
/// until the runtime's memory usage drops below the limit. | |
/// </para> | |
/// <para> | |
/// A runtime's memory limit can be always be set, regardless of whether or not the runtime is | |
/// active on another thread. | |
/// </para> | |
/// </remarks> | |
/// <param name="runtime">The runtime whose memory limit is to be set.</param> | |
/// <param name="memoryLimit"> | |
/// The new runtime memory limit, in bytes, or -1 for no memory limit. | |
/// </param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsSetRuntimeMemoryLimit(runtime: JsRuntimeHandle, memoryLimit: usize) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Sets a memory allocation callback for specified runtime | |
/// </summary> | |
/// <remarks> | |
/// <para> | |
/// Registering a memory allocation callback will cause the runtime to call back to the host | |
/// whenever it acquires memory from, or releases memory to, the OS. The callback routine is | |
/// called before the runtime memory manager allocates a block of memory. The allocation will | |
/// be rejected if the callback returns false. The runtime memory manager will also invoke the | |
/// callback routine after freeing a block of memory, as well as after allocation failures. | |
/// </para> | |
/// <para> | |
/// The callback is invoked on the current runtime execution thread, therefore execution is | |
/// blocked until the callback completes. | |
/// </para> | |
/// <para> | |
/// The return value of the callback is not stored; previously rejected allocations will not | |
/// prevent the runtime from invoking the callback again later for new memory allocations. | |
/// </para> | |
/// </remarks> | |
/// <param name="runtime">The runtime for which to register the allocation callback.</param> | |
/// <param name="callbackState"> | |
/// User provided state that will be passed back to the callback. | |
/// </param> | |
/// <param name="allocationCallback"> | |
/// Memory allocation callback to be called for memory allocation events. | |
/// </param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsSetRuntimeMemoryAllocationCallback(runtime: JsRuntimeHandle, | |
callbackState: *mut libc::c_void, | |
allocationCallback: JsMemoryAllocationCallback) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Sets a callback function that is called by the runtime before garbage collection. | |
/// </summary> | |
/// <remarks> | |
/// <para> | |
/// The callback is invoked on the current runtime execution thread, therefore execution is | |
/// blocked until the callback completes. | |
/// </para> | |
/// <para> | |
/// The callback can be used by hosts to prepare for garbage collection. For example, by | |
/// releasing unnecessary references on Chakra objects. | |
/// </para> | |
/// </remarks> | |
/// <param name="runtime">The runtime for which to register the allocation callback.</param> | |
/// <param name="callbackState"> | |
/// User provided state that will be passed back to the callback. | |
/// </param> | |
/// <param name="beforeCollectCallback">The callback function being set.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsSetRuntimeBeforeCollectCallback(runtime: JsRuntimeHandle, | |
callbackState: *mut libc::c_void, | |
beforeCollectCallback: JsBeforeCollectCallback) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Adds a reference to a garbage collected object. | |
/// </summary> | |
/// <remarks> | |
/// This only needs to be called on <c>JsRef</c> handles that are not going to be stored | |
/// somewhere on the stack. Calling <c>JsAddRef</c> ensures that the object the <c>JsRef</c> | |
/// refers to will not be freed until <c>JsRelease</c> is called. | |
/// </remarks> | |
/// <param name="ref">The object to add a reference to.</param> | |
/// <param name="count">The object's new reference count (can pass in null).</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsAddRef(ref_: JsRef, count: *mut libc::c_uint) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Releases a reference to a garbage collected object. | |
/// </summary> | |
/// <remarks> | |
/// Removes a reference to a <c>JsRef</c> handle that was created by <c>JsAddRef</c>. | |
/// </remarks> | |
/// <param name="ref">The object to add a reference to.</param> | |
/// <param name="count">The object's new reference count (can pass in null).</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsRelease(ref_: JsRef, count: *mut libc::c_uint) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Sets a callback function that is called by the runtime before garbage collection of | |
/// an object. | |
/// </summary> | |
/// <remarks> | |
/// <para> | |
/// The callback is invoked on the current runtime execution thread, therefore execution is | |
/// blocked until the callback completes. | |
/// </para> | |
/// </remarks> | |
/// <param name="ref">The object for which to register the callback.</param> | |
/// <param name="callbackState"> | |
/// User provided state that will be passed back to the callback. | |
/// </param> | |
/// <param name="objectBeforeCollectCallback">The callback function being set. Use null to clear | |
/// previously registered callback.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsSetObjectBeforeCollectCallback(ref_: JsRef, | |
callbackState: *mut libc::c_void, | |
objectBeforeCollectCallback: | |
JsObjectBeforeCollectCallback) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Creates a script context for running scripts. | |
/// </summary> | |
/// <remarks> | |
/// Each script context has its own global object that is isolated from all other script | |
/// contexts. | |
/// </remarks> | |
/// <param name="runtime">The runtime the script context is being created in.</param> | |
/// <param name="newContext">The created script context.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsCreateContext(runtime: JsRuntimeHandle, newContext: *mut JsContextRef) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Gets the current script context on the thread. | |
/// </summary> | |
/// <param name="currentContext"> | |
/// The current script context on the thread, null if there is no current script context. | |
/// </param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsGetCurrentContext(currentContext: *mut JsContextRef) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Sets the current script context on the thread. | |
/// </summary> | |
/// <param name="context">The script context to make current.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsSetCurrentContext(context: JsContextRef) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Gets the script context that the object belongs to. | |
/// </summary> | |
/// <param name="object">The object to get the context from.</param> | |
/// <param name="context">The context the object belongs to.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsGetContextOfObject(object: JsValueRef, context: *mut JsContextRef) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Gets the internal data set on JsrtContext. | |
/// </summary> | |
/// <param name="context">The context to get the data from.</param> | |
/// <param name="data">The pointer to the data where data will be returned.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsGetContextData(context: JsContextRef, data: *mut *mut libc::c_void) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Sets the internal data of JsrtContext. | |
/// </summary> | |
/// <param name="context">The context to set the data to.</param> | |
/// <param name="data">The pointer to the data to be set.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsSetContextData(context: JsContextRef, data: *mut libc::c_void) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Gets the runtime that the context belongs to. | |
/// </summary> | |
/// <param name="context">The context to get the runtime from.</param> | |
/// <param name="runtime">The runtime the context belongs to.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsGetRuntime(context: JsContextRef, runtime: *mut JsRuntimeHandle) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Tells the runtime to do any idle processing it need to do. | |
/// </summary> | |
/// <remarks> | |
/// <para> | |
/// If idle processing has been enabled for the current runtime, calling <c>JsIdle</c> will | |
/// inform the current runtime that the host is idle and that the runtime can perform | |
/// memory cleanup tasks. | |
/// </para> | |
/// <para> | |
/// <c>JsIdle</c> can also return the number of system ticks until there will be more idle work | |
/// for the runtime to do. Calling <c>JsIdle</c> before this number of ticks has passed will do | |
/// no work. | |
/// </para> | |
/// <para> | |
/// Requires an active script context. | |
/// </para> | |
/// </remarks> | |
/// <param name="nextIdleTick"> | |
/// The next system tick when there will be more idle work to do. Can be null. Returns the | |
/// maximum number of ticks if there no upcoming idle work to do. | |
/// </param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsIdle(nextIdleTick: *mut libc::c_uint) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Gets the symbol associated with the property ID. | |
/// </summary> | |
/// <remarks> | |
/// <para> | |
/// Requires an active script context. | |
/// </para> | |
/// </remarks> | |
/// <param name="propertyId">The property ID to get the symbol of.</param> | |
/// <param name="symbol">The symbol associated with the property ID.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsGetSymbolFromPropertyId(propertyId: JsPropertyIdRef, | |
symbol: *mut JsValueRef) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Gets the type of property | |
/// </summary> | |
/// <remarks> | |
/// <para> | |
/// Requires an active script context. | |
/// </para> | |
/// </remarks> | |
/// <param name="propertyId">The property ID to get the type of.</param> | |
/// <param name="propertyIdType">The JsPropertyIdType of the given property ID</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsGetPropertyIdType(propertyId: JsPropertyIdRef, | |
propertyIdType: *mut JsPropertyIdType) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Gets the property ID associated with the symbol. | |
/// </summary> | |
/// <remarks> | |
/// <para> | |
/// Property IDs are specific to a context and cannot be used across contexts. | |
/// </para> | |
/// <para> | |
/// Requires an active script context. | |
/// </para> | |
/// </remarks> | |
/// <param name="symbol"> | |
/// The symbol whose property ID is being retrieved. | |
/// </param> | |
/// <param name="propertyId">The property ID for the given symbol.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsGetPropertyIdFromSymbol(symbol: JsValueRef, | |
propertyId: *mut JsPropertyIdRef) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Creates a Javascript symbol. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="description">The string description of the symbol. Can be null.</param> | |
/// <param name="result">The new symbol.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsCreateSymbol(description: JsValueRef, result: *mut JsValueRef) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Gets the list of all symbol properties on the object. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="object">The object from which to get the property symbols.</param> | |
/// <param name="propertySymbols">An array of property symbols.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsGetOwnPropertySymbols(object: JsValueRef, | |
propertySymbols: *mut JsValueRef) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Gets the value of <c>undefined</c> in the current script context. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="undefinedValue">The <c>undefined</c> value.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsGetUndefinedValue(undefinedValue: *mut JsValueRef) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Gets the value of <c>null</c> in the current script context. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="nullValue">The <c>null</c> value.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsGetNullValue(nullValue: *mut JsValueRef) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Gets the value of <c>true</c> in the current script context. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="trueValue">The <c>true</c> value.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsGetTrueValue(trueValue: *mut JsValueRef) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Gets the value of <c>false</c> in the current script context. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="falseValue">The <c>false</c> value.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsGetFalseValue(falseValue: *mut JsValueRef) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Creates a Boolean value from a <c>bool</c> value. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="value">The value to be converted.</param> | |
/// <param name="booleanValue">The converted value.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsBoolToBoolean(value: bool, booleanValue: *mut JsValueRef) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Retrieves the <c>bool</c> value of a Boolean value. | |
/// </summary> | |
/// <param name="value">The value to be converted.</param> | |
/// <param name="boolValue">The converted value.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsBooleanToBool(value: JsValueRef, boolValue: *mut bool) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Converts the value to Boolean using standard JavaScript semantics. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="value">The value to be converted.</param> | |
/// <param name="booleanValue">The converted value.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsConvertValueToBoolean(value: JsValueRef, | |
booleanValue: *mut JsValueRef) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Gets the JavaScript type of a JsValueRef. | |
/// </summary> | |
/// <param name="value">The value whose type is to be returned.</param> | |
/// <param name="type">The type of the value.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsGetValueType(value: JsValueRef, type_: *mut JsValueType) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Creates a number value from a <c>double</c> value. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="doubleValue">The <c>double</c> to convert to a number value.</param> | |
/// <param name="value">The new number value.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsDoubleToNumber(doubleValue: f64, value: *mut JsValueRef) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Creates a number value from an <c>int</c> value. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="intValue">The <c>int</c> to convert to a number value.</param> | |
/// <param name="value">The new number value.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsIntToNumber(intValue: libc::c_int, value: *mut JsValueRef) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Retrieves the <c>double</c> value of a number value. | |
/// </summary> | |
/// <remarks> | |
/// This function retrieves the value of a number value. It will fail with | |
/// <c>JsErrorInvalidArgument</c> if the type of the value is not number. | |
/// </remarks> | |
/// <param name="value">The number value to convert to a <c>double</c> value.</param> | |
/// <param name="doubleValue">The <c>double</c> value.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsNumberToDouble(value: JsValueRef, doubleValue: *mut f64) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Retrieves the <c>int</c> value of a number value. | |
/// </summary> | |
/// <remarks> | |
/// This function retrieves the value of a number value and converts to an <c>int</c> value. | |
/// It will fail with <c>JsErrorInvalidArgument</c> if the type of the value is not number. | |
/// </remarks> | |
/// <param name="value">The number value to convert to an <c>int</c> value.</param> | |
/// <param name="intValue">The <c>int</c> value.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsNumberToInt(value: JsValueRef, intValue: *mut libc::c_int) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Converts the value to number using standard JavaScript semantics. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="value">The value to be converted.</param> | |
/// <param name="numberValue">The converted value.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsConvertValueToNumber(value: JsValueRef, numberValue: *mut JsValueRef) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Gets the length of a string value. | |
/// </summary> | |
/// <param name="stringValue">The string value to get the length of.</param> | |
/// <param name="length">The length of the string.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsGetStringLength(stringValue: JsValueRef, length: *mut libc::c_int) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Converts the value to string using standard JavaScript semantics. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="value">The value to be converted.</param> | |
/// <param name="stringValue">The converted value.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsConvertValueToString(value: JsValueRef, stringValue: *mut JsValueRef) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Gets the global object in the current script context. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="globalObject">The global object.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsGetGlobalObject(globalObject: *mut JsValueRef) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Creates a new object. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="object">The new object.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsCreateObject(object: *mut JsValueRef) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Creates a new object that stores some external data. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="data">External data that the object will represent. May be null.</param> | |
/// <param name="finalizeCallback"> | |
/// A callback for when the object is finalized. May be null. | |
/// </param> | |
/// <param name="object">The new object.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsCreateExternalObject(data: *mut libc::c_void, | |
finalizeCallback: JsFinalizeCallback, | |
object: *mut JsValueRef) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Converts the value to object using standard JavaScript semantics. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="value">The value to be converted.</param> | |
/// <param name="object">The converted value.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsConvertValueToObject(value: JsValueRef, object: *mut JsValueRef) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Returns the prototype of an object. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="object">The object whose prototype is to be returned.</param> | |
/// <param name="prototypeObject">The object's prototype.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsGetPrototype(object: JsValueRef, prototypeObject: *mut JsValueRef) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Sets the prototype of an object. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="object">The object whose prototype is to be changed.</param> | |
/// <param name="prototypeObject">The object's new prototype.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsSetPrototype(object: JsValueRef, prototypeObject: JsValueRef) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Performs JavaScript "instanceof" operator test. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="object">The object to test.</param> | |
/// <param name="constructor">The constructor function to test against.</param> | |
/// <param name="result">Whether "object instanceof constructor" is true.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsInstanceOf(object: JsValueRef, | |
constructor: JsValueRef, | |
result: *mut bool) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Returns a value that indicates whether an object is extensible or not. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="object">The object to test.</param> | |
/// <param name="value">Whether the object is extensible or not.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsGetExtensionAllowed(object: JsValueRef, value: *mut bool) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Makes an object non-extensible. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="object">The object to make non-extensible.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsPreventExtension(object: JsValueRef) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Gets an object's property. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="object">The object that contains the property.</param> | |
/// <param name="propertyId">The ID of the property.</param> | |
/// <param name="value">The value of the property.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsGetProperty(object: JsValueRef, | |
propertyId: JsPropertyIdRef, | |
value: *mut JsValueRef) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Gets a property descriptor for an object's own property. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="object">The object that has the property.</param> | |
/// <param name="propertyId">The ID of the property.</param> | |
/// <param name="propertyDescriptor">The property descriptor.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsGetOwnPropertyDescriptor(object: JsValueRef, | |
propertyId: JsPropertyIdRef, | |
propertyDescriptor: *mut JsValueRef) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Gets the list of all properties on the object. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="object">The object from which to get the property names.</param> | |
/// <param name="propertyNames">An array of property names.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsGetOwnPropertyNames(object: JsValueRef, | |
propertyNames: *mut JsValueRef) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Puts an object's property. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="object">The object that contains the property.</param> | |
/// <param name="propertyId">The ID of the property.</param> | |
/// <param name="value">The new value of the property.</param> | |
/// <param name="useStrictRules">The property set should follow strict mode rules.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsSetProperty(object: JsValueRef, | |
propertyId: JsPropertyIdRef, | |
value: JsValueRef, | |
useStrictRules: bool) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Determines whether an object has a property. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="object">The object that may contain the property.</param> | |
/// <param name="propertyId">The ID of the property.</param> | |
/// <param name="hasProperty">Whether the object (or a prototype) has the property.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsHasProperty(object: JsValueRef, | |
propertyId: JsPropertyIdRef, | |
hasProperty: *mut bool) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Deletes an object's property. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="object">The object that contains the property.</param> | |
/// <param name="propertyId">The ID of the property.</param> | |
/// <param name="useStrictRules">The property set should follow strict mode rules.</param> | |
/// <param name="result">Whether the property was deleted.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsDeleteProperty(object: JsValueRef, | |
propertyId: JsPropertyIdRef, | |
useStrictRules: bool, | |
result: *mut JsValueRef) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Defines a new object's own property from a property descriptor. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="object">The object that has the property.</param> | |
/// <param name="propertyId">The ID of the property.</param> | |
/// <param name="propertyDescriptor">The property descriptor.</param> | |
/// <param name="result">Whether the property was defined.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsDefineProperty(object: JsValueRef, | |
propertyId: JsPropertyIdRef, | |
propertyDescriptor: JsValueRef, | |
result: *mut bool) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Tests whether an object has a value at the specified index. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="object">The object to operate on.</param> | |
/// <param name="index">The index to test.</param> | |
/// <param name="result">Whether the object has a value at the specified index.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsHasIndexedProperty(object: JsValueRef, | |
index: JsValueRef, | |
result: *mut bool) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Retrieve the value at the specified index of an object. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="object">The object to operate on.</param> | |
/// <param name="index">The index to retrieve.</param> | |
/// <param name="result">The retrieved value.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsGetIndexedProperty(object: JsValueRef, | |
index: JsValueRef, | |
result: *mut JsValueRef) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Set the value at the specified index of an object. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="object">The object to operate on.</param> | |
/// <param name="index">The index to set.</param> | |
/// <param name="value">The value to set.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsSetIndexedProperty(object: JsValueRef, | |
index: JsValueRef, | |
value: JsValueRef) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Delete the value at the specified index of an object. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="object">The object to operate on.</param> | |
/// <param name="index">The index to delete.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsDeleteIndexedProperty(object: JsValueRef, index: JsValueRef) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Determines whether an object has its indexed properties in external data. | |
/// </summary> | |
/// <param name="object">The object.</param> | |
/// <param name="value">Whether the object has its indexed properties in external data.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsHasIndexedPropertiesExternalData(object: JsValueRef, value: *mut bool) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Retrieves an object's indexed properties external data information. | |
/// </summary> | |
/// <param name="object">The object.</param> | |
/// <param name="data">The external data back store for the object's indexed properties.</param> | |
/// <param name="arrayType">The array element type in external data.</param> | |
/// <param name="elementLength">The number of array elements in external data.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsGetIndexedPropertiesExternalData(object: JsValueRef, | |
data: *mut *mut libc::c_void, | |
arrayType: *mut JsTypedArrayType, | |
elementLength: *mut libc::c_uint) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Sets an object's indexed properties to external data. The external data will be used as back | |
/// store for the object's indexed properties and accessed like a typed array. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="object">The object to operate on.</param> | |
/// <param name="data">The external data to be used as back store for the object's indexed properties.</param> | |
/// <param name="arrayType">The array element type in external data.</param> | |
/// <param name="elementLength">The number of array elements in external data.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsSetIndexedPropertiesToExternalData(object: JsValueRef, | |
data: *mut libc::c_void, | |
arrayType: JsTypedArrayType, | |
elementLength: libc::c_uint) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Compare two JavaScript values for equality. | |
/// </summary> | |
/// <remarks> | |
/// <para> | |
/// This function is equivalent to the <c>==</c> operator in Javascript. | |
/// </para> | |
/// <para> | |
/// Requires an active script context. | |
/// </para> | |
/// </remarks> | |
/// <param name="object1">The first object to compare.</param> | |
/// <param name="object2">The second object to compare.</param> | |
/// <param name="result">Whether the values are equal.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsEquals(object1: JsValueRef, object2: JsValueRef, result: *mut bool) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Compare two JavaScript values for strict equality. | |
/// </summary> | |
/// <remarks> | |
/// <para> | |
/// This function is equivalent to the <c>===</c> operator in Javascript. | |
/// </para> | |
/// <para> | |
/// Requires an active script context. | |
/// </para> | |
/// </remarks> | |
/// <param name="object1">The first object to compare.</param> | |
/// <param name="object2">The second object to compare.</param> | |
/// <param name="result">Whether the values are strictly equal.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsStrictEquals(object1: JsValueRef, | |
object2: JsValueRef, | |
result: *mut bool) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Determines whether an object is an external object. | |
/// </summary> | |
/// <param name="object">The object.</param> | |
/// <param name="value">Whether the object is an external object.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsHasExternalData(object: JsValueRef, value: *mut bool) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Retrieves the data from an external object. | |
/// </summary> | |
/// <param name="object">The external object.</param> | |
/// <param name="externalData"> | |
/// The external data stored in the object. Can be null if no external data is stored in the | |
/// object. | |
/// </param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsGetExternalData(object: JsValueRef, | |
externalData: *mut *mut libc::c_void) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Sets the external data on an external object. | |
/// </summary> | |
/// <param name="object">The external object.</param> | |
/// <param name="externalData"> | |
/// The external data to be stored in the object. Can be null if no external data is | |
/// to be stored in the object. | |
/// </param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsSetExternalData(object: JsValueRef, externalData: *mut libc::c_void) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Creates a Javascript array object. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="length">The initial length of the array.</param> | |
/// <param name="result">The new array object.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsCreateArray(length: libc::c_uint, result: *mut JsValueRef) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Creates a Javascript ArrayBuffer object. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="byteLength"> | |
/// The number of bytes in the ArrayBuffer. | |
/// </param> | |
/// <param name="result">The new ArrayBuffer object.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsCreateArrayBuffer(byteLength: libc::c_uint, result: *mut JsValueRef) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Creates a Javascript ArrayBuffer object to access external memory. | |
/// </summary> | |
/// <remarks>Requires an active script context.</remarks> | |
/// <param name="data">A pointer to the external memory.</param> | |
/// <param name="byteLength">The number of bytes in the external memory.</param> | |
/// <param name="finalizeCallback">A callback for when the object is finalized. May be null.</param> | |
/// <param name="callbackState">User provided state that will be passed back to finalizeCallback.</param> | |
/// <param name="result">The new ArrayBuffer object.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsCreateExternalArrayBuffer(data: *mut libc::c_void, | |
byteLength: libc::c_uint, | |
finalizeCallback: JsFinalizeCallback, | |
callbackState: *mut libc::c_void, | |
result: *mut JsValueRef) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Creates a Javascript typed array object. | |
/// </summary> | |
/// <remarks> | |
/// <para> | |
/// The <c>baseArray</c> can be an <c>ArrayBuffer</c>, another typed array, or a JavaScript | |
/// <c>Array</c>. The returned typed array will use the baseArray if it is an ArrayBuffer, or | |
/// otherwise create and use a copy of the underlying source array. | |
/// </para> | |
/// <para> | |
/// Requires an active script context. | |
/// </para> | |
/// </remarks> | |
/// <param name="arrayType">The type of the array to create.</param> | |
/// <param name="baseArray"> | |
/// The base array of the new array. Use <c>JS_INVALID_REFERENCE</c> if no base array. | |
/// </param> | |
/// <param name="byteOffset"> | |
/// The offset in bytes from the start of baseArray (ArrayBuffer) for result typed array to reference. | |
/// Only applicable when baseArray is an ArrayBuffer object. Must be 0 otherwise. | |
/// </param> | |
/// <param name="elementLength"> | |
/// The number of elements in the array. Only applicable when creating a new typed array without | |
/// baseArray (baseArray is <c>JS_INVALID_REFERENCE</c>) or when baseArray is an ArrayBuffer object. | |
/// Must be 0 otherwise. | |
/// </param> | |
/// <param name="result">The new typed array object.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsCreateTypedArray(arrayType: JsTypedArrayType, | |
baseArray: JsValueRef, | |
byteOffset: libc::c_uint, | |
elementLength: libc::c_uint, | |
result: *mut JsValueRef) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Creates a Javascript DataView object. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="arrayBuffer"> | |
/// An existing ArrayBuffer object to use as the storage for the result DataView object. | |
/// </param> | |
/// <param name="byteOffset"> | |
/// The offset in bytes from the start of arrayBuffer for result DataView to reference. | |
/// </param> | |
/// <param name="byteLength"> | |
/// The number of bytes in the ArrayBuffer for result DataView to reference. | |
/// </param> | |
/// <param name="result">The new DataView object.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsCreateDataView(arrayBuffer: JsValueRef, | |
byteOffset: libc::c_uint, | |
byteLength: libc::c_uint, | |
result: *mut JsValueRef) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Obtains frequently used properties of a typed array. | |
/// </summary> | |
/// <param name="typedArray">The typed array instance.</param> | |
/// <param name="arrayType">The type of the array.</param> | |
/// <param name="arrayBuffer">The ArrayBuffer backstore of the array.</param> | |
/// <param name="byteOffset">The offset in bytes from the start of arrayBuffer referenced by the array.</param> | |
/// <param name="byteLength">The number of bytes in the array.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsGetTypedArrayInfo(typedArray: JsValueRef, | |
arrayType: *mut JsTypedArrayType, | |
arrayBuffer: *mut JsValueRef, | |
byteOffset: *mut libc::c_uint, | |
byteLength: *mut libc::c_uint) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Obtains the underlying memory storage used by an <c>ArrayBuffer</c>. | |
/// </summary> | |
/// <param name="arrayBuffer">The ArrayBuffer instance.</param> | |
/// <param name="buffer"> | |
/// The ArrayBuffer's buffer. The lifetime of the buffer returned is the same as the lifetime of the | |
/// the ArrayBuffer. The buffer pointer does not count as a reference to the ArrayBuffer for the purpose | |
/// of garbage collection. | |
/// </param> | |
/// <param name="bufferLength">The number of bytes in the buffer.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsGetArrayBufferStorage(arrayBuffer: JsValueRef, | |
buffer: *mut ChakraBytePtr, | |
bufferLength: *mut libc::c_uint) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Obtains the underlying memory storage used by a typed array. | |
/// </summary> | |
/// <param name="typedArray">The typed array instance.</param> | |
/// <param name="buffer"> | |
/// The array's buffer. The lifetime of the buffer returned is the same as the lifetime of the | |
/// the array. The buffer pointer does not count as a reference to the array for the purpose | |
/// of garbage collection. | |
/// </param> | |
/// <param name="bufferLength">The number of bytes in the buffer.</param> | |
/// <param name="arrayType">The type of the array.</param> | |
/// <param name="elementSize"> | |
/// The size of an element of the array. | |
/// </param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsGetTypedArrayStorage(typedArray: JsValueRef, | |
buffer: *mut ChakraBytePtr, | |
bufferLength: *mut libc::c_uint, | |
arrayType: *mut JsTypedArrayType, | |
elementSize: *mut libc::c_int) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Obtains the underlying memory storage used by a DataView. | |
/// </summary> | |
/// <param name="dataView">The DataView instance.</param> | |
/// <param name="buffer"> | |
/// The DataView's buffer. The lifetime of the buffer returned is the same as the lifetime of the | |
/// the DataView. The buffer pointer does not count as a reference to the DataView for the purpose | |
/// of garbage collection. | |
/// </param> | |
/// <param name="bufferLength">The number of bytes in the buffer.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsGetDataViewStorage(dataView: JsValueRef, | |
buffer: *mut ChakraBytePtr, | |
bufferLength: *mut libc::c_uint) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Invokes a function. | |
/// </summary> | |
/// <remarks> | |
/// Requires thisArg as first argument of arguments. | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="function">The function to invoke.</param> | |
/// <param name="arguments">The arguments to the call.</param> | |
/// <param name="argumentCount">The number of arguments being passed in to the function.</param> | |
/// <param name="result">The value returned from the function invocation, if any.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsCallFunction(function: JsValueRef, | |
arguments: *mut JsValueRef, | |
argumentCount: libc::c_ushort, | |
result: *mut JsValueRef) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Invokes a function as a constructor. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="function">The function to invoke as a constructor.</param> | |
/// <param name="arguments">The arguments to the call.</param> | |
/// <param name="argumentCount">The number of arguments being passed in to the function.</param> | |
/// <param name="result">The value returned from the function invocation.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsConstructObject(function: JsValueRef, | |
arguments: *mut JsValueRef, | |
argumentCount: libc::c_ushort, | |
result: *mut JsValueRef) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Creates a new JavaScript function. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="nativeFunction">The method to call when the function is invoked.</param> | |
/// <param name="callbackState"> | |
/// User provided state that will be passed back to the callback. | |
/// </param> | |
/// <param name="function">The new function object.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsCreateFunction(nativeFunction: JsNativeFunction, | |
callbackState: *mut libc::c_void, | |
function: *mut JsValueRef) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Creates a new JavaScript function with name. | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="name">The name of this function that will be used for diagnostics and stringification purposes.</param> | |
/// <param name="nativeFunction">The method to call when the function is invoked.</param> | |
/// <param name="callbackState"> | |
/// User provided state that will be passed back to the callback. | |
/// </param> | |
/// <param name="function">The new function object.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsCreateNamedFunction(name: JsValueRef, | |
nativeFunction: JsNativeFunction, | |
callbackState: *mut libc::c_void, | |
function: *mut JsValueRef) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Creates a new JavaScript error object | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="message">Message for the error object.</param> | |
/// <param name="error">The new error object.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsCreateError(message: JsValueRef, error: *mut JsValueRef) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Creates a new JavaScript RangeError error object | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="message">Message for the error object.</param> | |
/// <param name="error">The new error object.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsCreateRangeError(message: JsValueRef, error: *mut JsValueRef) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Creates a new JavaScript ReferenceError error object | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="message">Message for the error object.</param> | |
/// <param name="error">The new error object.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsCreateReferenceError(message: JsValueRef, error: *mut JsValueRef) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Creates a new JavaScript SyntaxError error object | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="message">Message for the error object.</param> | |
/// <param name="error">The new error object.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsCreateSyntaxError(message: JsValueRef, error: *mut JsValueRef) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Creates a new JavaScript TypeError error object | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="message">Message for the error object.</param> | |
/// <param name="error">The new error object.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsCreateTypeError(message: JsValueRef, error: *mut JsValueRef) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Creates a new JavaScript URIError error object | |
/// </summary> | |
/// <remarks> | |
/// Requires an active script context. | |
/// </remarks> | |
/// <param name="message">Message for the error object.</param> | |
/// <param name="error">The new error object.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsCreateURIError(message: JsValueRef, error: *mut JsValueRef) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Determines whether the runtime of the current context is in an exception state. | |
/// </summary> | |
/// <remarks> | |
/// <para> | |
/// If a call into the runtime results in an exception (either as the result of running a | |
/// script or due to something like a conversion failure), the runtime is placed into an | |
/// "exception state." All calls into any context created by the runtime (except for the | |
/// exception APIs) will fail with <c>JsErrorInExceptionState</c> until the exception is | |
/// cleared. | |
/// </para> | |
/// <para> | |
/// If the runtime of the current context is in the exception state when a callback returns | |
/// into the engine, the engine will automatically rethrow the exception. | |
/// </para> | |
/// <para> | |
/// Requires an active script context. | |
/// </para> | |
/// </remarks> | |
/// <param name="hasException"> | |
/// Whether the runtime of the current context is in the exception state. | |
/// </param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsHasException(hasException: *mut bool) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Returns the exception that caused the runtime of the current context to be in the | |
/// exception state and resets the exception state for that runtime. | |
/// </summary> | |
/// <remarks> | |
/// <para> | |
/// If the runtime of the current context is not in an exception state, this API will return | |
/// <c>JsErrorInvalidArgument</c>. If the runtime is disabled, this will return an exception | |
/// indicating that the script was terminated, but it will not clear the exception (the | |
/// exception will be cleared if the runtime is re-enabled using | |
/// <c>JsEnableRuntimeExecution</c>). | |
/// </para> | |
/// <para> | |
/// Requires an active script context. | |
/// </para> | |
/// </remarks> | |
/// <param name="exception">The exception for the runtime of the current context.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsGetAndClearException(exception: *mut JsValueRef) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Sets the runtime of the current context to an exception state. | |
/// </summary> | |
/// <remarks> | |
/// <para> | |
/// If the runtime of the current context is already in an exception state, this API will | |
/// return <c>JsErrorInExceptionState</c>. | |
/// </para> | |
/// <para> | |
/// Requires an active script context. | |
/// </para> | |
/// </remarks> | |
/// <param name="exception"> | |
/// The JavaScript exception to set for the runtime of the current context. | |
/// </param> | |
/// <returns> | |
/// JsNoError if the engine was set into an exception state, a failure code otherwise. | |
/// </returns> | |
pub fn JsSetException(exception: JsValueRef) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Suspends script execution and terminates any running scripts in a runtime. | |
/// </summary> | |
/// <remarks> | |
/// <para> | |
/// Calls to a suspended runtime will fail until <c>JsEnableRuntimeExecution</c> is called. | |
/// </para> | |
/// <para> | |
/// This API does not have to be called on the thread the runtime is active on. Although the | |
/// runtime will be set into a suspended state, an executing script may not be suspended | |
/// immediately; a running script will be terminated with an uncatchable exception as soon as | |
/// possible. | |
/// </para> | |
/// <para> | |
/// Suspending execution in a runtime that is already suspended is a no-op. | |
/// </para> | |
/// </remarks> | |
/// <param name="runtime">The runtime to be suspended.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsDisableRuntimeExecution(runtime: JsRuntimeHandle) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Enables script execution in a runtime. | |
/// </summary> | |
/// <remarks> | |
/// Enabling script execution in a runtime that already has script execution enabled is a | |
/// no-op. | |
/// </remarks> | |
/// <param name="runtime">The runtime to be enabled.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsEnableRuntimeExecution(runtime: JsRuntimeHandle) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Returns a value that indicates whether script execution is disabled in the runtime. | |
/// </summary> | |
/// <param name="runtime">Specifies the runtime to check if execution is disabled.</param> | |
/// <param name="isDisabled">If execution is disabled, <c>true</c>, <c>false</c> otherwise.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsIsRuntimeExecutionDisabled(runtime: JsRuntimeHandle, | |
isDisabled: *mut bool) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Sets a promise continuation callback function that is called by the context when a task | |
/// needs to be queued for future execution | |
/// </summary> | |
/// <remarks> | |
/// <para> | |
/// Requires an active script context. | |
/// </para> | |
/// </remarks> | |
/// <param name="promiseContinuationCallback">The callback function being set.</param> | |
/// <param name="callbackState"> | |
/// User provided state that will be passed back to the callback. | |
/// </param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsSetPromiseContinuationCallback(promiseContinuationCallback: | |
JsPromiseContinuationCallback, | |
callbackState: *mut libc::c_void) | |
-> JsErrorCode; | |
} | |
#[repr(u32)] | |
/// <summary> | |
/// Debug events reported from ChakraCore engine. | |
/// </summary> | |
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | |
pub enum JsDiagDebugEvent { | |
SourceCompile = 0, | |
CompileError = 1, | |
Breakpoint = 2, | |
StepComplete = 3, | |
DebuggerStatement = 4, | |
AsyncBreak = 5, | |
RuntimeException = 6, | |
} | |
pub const JsDiagBreakOnExceptionAttributeNone: JsDiagBreakOnExceptionAttributes = | |
JsDiagBreakOnExceptionAttributes(0); | |
pub const JsDiagBreakOnExceptionAttributeUncaught: JsDiagBreakOnExceptionAttributes = | |
JsDiagBreakOnExceptionAttributes(1); | |
pub const JsDiagBreakOnExceptionAttributeFirstChance: JsDiagBreakOnExceptionAttributes = | |
JsDiagBreakOnExceptionAttributes(2); | |
impl ::std::ops::BitOr<JsDiagBreakOnExceptionAttributes> for JsDiagBreakOnExceptionAttributes { | |
type Output = Self; | |
#[inline] | |
fn bitor(self, other: Self) -> Self { | |
JsDiagBreakOnExceptionAttributes(self.0 | other.0) | |
} | |
} | |
#[repr(C)] | |
/// <summary> | |
/// Break on Exception attributes. | |
/// </summary> | |
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | |
pub struct JsDiagBreakOnExceptionAttributes(pub u32); | |
#[repr(u32)] | |
/// <summary> | |
/// Stepping types. | |
/// </summary> | |
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | |
pub enum JsDiagStepType { | |
StepIn = 0, | |
StepOut = 1, | |
StepOver = 2, | |
StepBack = 3, | |
StepReverseContinue = 4, | |
} | |
/// <summary> | |
/// User implemented callback routine for debug events. | |
/// </summary> | |
/// <remarks> | |
/// Use <c>JsDiagStartDebugging</c> to register the callback. | |
/// </remarks> | |
/// <param name="debugEvent">The type of JsDiagDebugEvent event.</param> | |
/// <param name="eventData">Additional data related to the debug event.</param> | |
/// <param name="callbackState">The state passed to <c>JsDiagStartDebugging</c>.</param> | |
pub type JsDiagDebugEventCallback = | |
::std::option::Option<unsafe extern "system" fn(debugEvent: JsDiagDebugEvent, | |
eventData: JsValueRef, | |
callbackState: *mut libc::c_void)>; | |
extern "system" { | |
/// <summary> | |
/// Starts debugging in the given runtime. | |
/// </summary> | |
/// <param name="runtimeHandle">Runtime to put into debug mode.</param> | |
/// <param name="debugEventCallback">Registers a callback to be called on every JsDiagDebugEvent.</param> | |
/// <param name="callbackState">User provided state that will be passed back to the callback.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
/// <remarks> | |
/// The runtime should be active on the current thread and should not be in debug state. | |
/// </remarks> | |
pub fn JsDiagStartDebugging(runtimeHandle: JsRuntimeHandle, | |
debugEventCallback: JsDiagDebugEventCallback, | |
callbackState: *mut libc::c_void) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Stops debugging in the given runtime. | |
/// </summary> | |
/// <param name="runtimeHandle">Runtime to stop debugging.</param> | |
/// <param name="callbackState">User provided state that was passed in JsDiagStartDebugging.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
/// <remarks> | |
/// The runtime should be active on the current thread and in debug state. | |
/// </remarks> | |
pub fn JsDiagStopDebugging(runtimeHandle: JsRuntimeHandle, | |
callbackState: *mut *mut libc::c_void) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Request the runtime to break on next JavaScript statement. | |
/// </summary> | |
/// <param name="runtimeHandle">Runtime to request break.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
/// <remarks> | |
/// The runtime should be in debug state. This API can be called from another runtime. | |
/// </remarks> | |
pub fn JsDiagRequestAsyncBreak(runtimeHandle: JsRuntimeHandle) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// List all breakpoints in the current runtime. | |
/// </summary> | |
/// <param name="breakpoints">Array of breakpoints.</param> | |
/// <remarks> | |
/// <para> | |
/// [{ | |
/// "breakpointId" : 1, | |
/// "scriptId" : 1, | |
/// "line" : 0, | |
/// "column" : 62 | |
/// }] | |
/// </para> | |
/// </remarks> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
/// <remarks> | |
/// The current runtime should be in debug state. This API can be called when runtime is at a break or running. | |
/// </remarks> | |
pub fn JsDiagGetBreakpoints(breakpoints: *mut JsValueRef) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Sets breakpoint in the specified script at give location. | |
/// </summary> | |
/// <param name="scriptId">Id of script from JsDiagGetScripts or JsDiagGetSource to put breakpoint.</param> | |
/// <param name="lineNumber">0 based line number to put breakpoint.</param> | |
/// <param name="columnNumber">0 based column number to put breakpoint.</param> | |
/// <param name="breakpoint">Breakpoint object with id, line and column if success.</param> | |
/// <remarks> | |
/// <para> | |
/// { | |
/// "breakpointId" : 1, | |
/// "line" : 2, | |
/// "column" : 4 | |
/// } | |
/// </para> | |
/// </remarks> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
/// <remarks> | |
/// The current runtime should be in debug state. This API can be called when runtime is at a break or running. | |
/// </remarks> | |
pub fn JsDiagSetBreakpoint(scriptId: libc::c_uint, | |
lineNumber: libc::c_uint, | |
columnNumber: libc::c_uint, | |
breakpoint: *mut JsValueRef) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Remove a breakpoint. | |
/// </summary> | |
/// <param name="breakpointId">Breakpoint id returned from JsDiagSetBreakpoint.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
/// <remarks> | |
/// The current runtime should be in debug state. This API can be called when runtime is at a break or running. | |
/// </remarks> | |
pub fn JsDiagRemoveBreakpoint(breakpointId: libc::c_uint) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Sets break on exception handling. | |
/// </summary> | |
/// <param name="runtimeHandle">Runtime to set break on exception attributes.</param> | |
/// <param name="exceptionAttributes">Mask of JsDiagBreakOnExceptionAttributes to set.</param> | |
/// <remarks> | |
/// <para> | |
/// If this API is not called the default value is set to JsDiagBreakOnExceptionAttributeUncaught in the runtime. | |
/// </para> | |
/// </remarks> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
/// <remarks> | |
/// The runtime should be in debug state. This API can be called from another runtime. | |
/// </remarks> | |
pub fn JsDiagSetBreakOnException(runtimeHandle: JsRuntimeHandle, | |
exceptionAttributes: JsDiagBreakOnExceptionAttributes) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Gets break on exception setting. | |
/// </summary> | |
/// <param name="runtimeHandle">Runtime from which to get break on exception attributes, should be in debug mode.</param> | |
/// <param name="exceptionAttributes">Mask of JsDiagBreakOnExceptionAttributes.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
/// <remarks> | |
/// The runtime should be in debug state. This API can be called from another runtime. | |
/// </remarks> | |
pub fn JsDiagGetBreakOnException(runtimeHandle: JsRuntimeHandle, | |
exceptionAttributes: *mut JsDiagBreakOnExceptionAttributes) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Sets the step type in the runtime after a debug break. | |
/// </summary> | |
/// <remarks> | |
/// Requires to be at a debug break. | |
/// </remarks> | |
/// <param name="resumeType">Type of JsDiagStepType.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
/// <remarks> | |
/// The current runtime should be in debug state. This API can only be called when runtime is at a break. | |
/// </remarks> | |
pub fn JsDiagSetStepType(stepType: JsDiagStepType) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Gets list of scripts. | |
/// </summary> | |
/// <param name="scriptsArray">Array of script objects.</param> | |
/// <remarks> | |
/// <para> | |
/// [{ | |
/// "scriptId" : 2, | |
/// "fileName" : "c:\\Test\\Test.js", | |
/// "lineCount" : 4, | |
/// "sourceLength" : 111 | |
/// }, { | |
/// "scriptId" : 3, | |
/// "parentScriptId" : 2, | |
/// "scriptType" : "eval code", | |
/// "lineCount" : 1, | |
/// "sourceLength" : 12 | |
/// }] | |
/// </para> | |
/// </remarks> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
/// <remarks> | |
/// The current runtime should be in debug state. This API can be called when runtime is at a break or running. | |
/// </remarks> | |
pub fn JsDiagGetScripts(scriptsArray: *mut JsValueRef) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Gets source for a specific script identified by scriptId from JsDiagGetScripts. | |
/// </summary> | |
/// <param name="scriptId">Id of the script.</param> | |
/// <param name="source">Source object.</param> | |
/// <remarks> | |
/// <para> | |
/// { | |
/// "scriptId" : 1, | |
/// "fileName" : "c:\\Test\\Test.js", | |
/// "lineCount" : 12, | |
/// "sourceLength" : 15154, | |
/// "source" : "var x = 1;" | |
/// } | |
/// </para> | |
/// </remarks> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
/// <remarks> | |
/// The current runtime should be in debug state. This API can be called when runtime is at a break or running. | |
/// </remarks> | |
pub fn JsDiagGetSource(scriptId: libc::c_uint, source: *mut JsValueRef) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Gets the source information for a function object. | |
/// </summary> | |
/// <param name="function">JavaScript function.</param> | |
/// <param name="functionPosition">Function position - scriptId, start line, start column, line number of first statement, column number of first statement.</param> | |
/// <remarks> | |
/// <para> | |
/// { | |
/// "scriptId" : 1, | |
/// "fileName" : "c:\\Test\\Test.js", | |
/// "line" : 1, | |
/// "column" : 2, | |
/// "firstStatementLine" : 6, | |
/// "firstStatementColumn" : 0 | |
/// } | |
/// </para> | |
/// </remarks> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
/// <remarks> | |
/// This API can be called when runtime is at a break or running. | |
/// </remarks> | |
pub fn JsDiagGetFunctionPosition(function: JsValueRef, | |
functionPosition: *mut JsValueRef) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Gets the stack trace information. | |
/// </summary> | |
/// <param name="stackTrace">Stack trace information.</param> | |
/// <remarks> | |
/// <para> | |
/// [{ | |
/// "index" : 0, | |
/// "scriptId" : 2, | |
/// "line" : 3, | |
/// "column" : 0, | |
/// "sourceLength" : 9, | |
/// "sourceText" : "var x = 1", | |
/// "functionHandle" : 1 | |
/// }] | |
/// </para> | |
/// </remarks> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
/// <remarks> | |
/// The current runtime should be in debug state. This API can only be called when runtime is at a break. | |
/// </remarks> | |
pub fn JsDiagGetStackTrace(stackTrace: *mut JsValueRef) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Gets the list of properties corresponding to the frame. | |
/// </summary> | |
/// <param name="stackFrameIndex">Index of stack frame from JsDiagGetStackTrace.</param> | |
/// <param name="properties">Object of properties array (properties, scopes and globals).</param> | |
/// <remarks> | |
/// <para> | |
/// propertyAttributes is a bit mask of | |
/// NONE = 0x1, | |
/// HAVE_CHILDRENS = 0x2, | |
/// READ_ONLY_VALUE = 0x4, | |
/// </para> | |
/// </remarks> | |
/// <remarks> | |
/// <para> | |
/// { | |
/// "thisObject": { | |
/// "name": "this", | |
/// "type" : "object", | |
/// "className" : "Object", | |
/// "display" : "{...}", | |
/// "propertyAttributes" : 1, | |
/// "handle" : 306 | |
/// }, | |
/// "exception" : { | |
/// "name" : "{exception}", | |
/// "type" : "object", | |
/// "display" : "'a' is undefined", | |
/// "className" : "Error", | |
/// "propertyAttributes" : 1, | |
/// "handle" : 307 | |
/// } | |
/// "arguments" : { | |
/// "name" : "arguments", | |
/// "type" : "object", | |
/// "display" : "{...}", | |
/// "className" : "Object", | |
/// "propertyAttributes" : 1, | |
/// "handle" : 190 | |
/// }, | |
/// "returnValue" : { | |
/// "name" : "[Return value]", | |
/// "type" : "undefined", | |
/// "propertyAttributes" : 0, | |
/// "handle" : 192 | |
/// }, | |
/// "functionCallsReturn" : [{ | |
/// "name" : "[foo1 returned]", | |
/// "type" : "number", | |
/// "value" : 1, | |
/// "propertyAttributes" : 2, | |
/// "handle" : 191 | |
/// } | |
/// ], | |
/// "locals" : [], | |
/// "scopes" : [{ | |
/// "index" : 0, | |
/// "handle" : 193 | |
/// } | |
/// ], | |
/// "globals" : { | |
/// "handle" : 194 | |
/// } | |
/// } | |
/// </para> | |
/// </remarks> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
/// <remarks> | |
/// The current runtime should be in debug state. This API can only be called when runtime is at a break. | |
/// </remarks> | |
pub fn JsDiagGetStackProperties(stackFrameIndex: libc::c_uint, | |
properties: *mut JsValueRef) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Gets the list of children of a handle. | |
/// </summary> | |
/// <param name="objectHandle">Handle of object.</param> | |
/// <param name="fromCount">0-based from count of properties, usually 0.</param> | |
/// <param name="totalCount">Number of properties to return.</param> | |
/// <param name="propertiesObject">Array of properties.</param> | |
/// <remarks>Handle should be from objects returned from call to JsDiagGetStackProperties.</remarks> | |
/// <remarks>For scenarios where object have large number of properties totalCount can be used to control how many properties are given.</remarks> | |
/// <remarks> | |
/// <para> | |
/// { | |
/// "totalPropertiesOfObject": 10, | |
/// "properties" : [{ | |
/// "name" : "_proto__", | |
/// "type" : "object", | |
/// "display" : "{...}", | |
/// "className" : "Object", | |
/// "propertyAttributes" : 1, | |
/// "handle" : 156 | |
/// } | |
/// ], | |
/// "debuggerOnlyProperties" : [{ | |
/// "name" : "[Map]", | |
/// "type" : "string", | |
/// "value" : "size = 0", | |
/// "propertyAttributes" : 2, | |
/// "handle" : 157 | |
/// } | |
/// ] | |
/// } | |
/// </para> | |
/// </remarks> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
/// <remarks> | |
/// The current runtime should be in debug state. This API can only be called when runtime is at a break. | |
/// </remarks> | |
pub fn JsDiagGetProperties(objectHandle: libc::c_uint, | |
fromCount: libc::c_uint, | |
totalCount: libc::c_uint, | |
propertiesObject: *mut JsValueRef) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Gets the object corresponding to handle. | |
/// </summary> | |
/// <param name="objectHandle">Handle of object.</param> | |
/// <param name="handleObject">Object corresponding to the handle.</param> | |
/// <remarks> | |
/// <para> | |
/// { | |
/// "scriptId" : 24, | |
/// "line" : 1, | |
/// "column" : 63, | |
/// "name" : "foo", | |
/// "type" : "function", | |
/// "handle" : 2 | |
/// } | |
/// </para> | |
/// </remarks> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
/// <remarks> | |
/// The current runtime should be in debug state. This API can only be called when runtime is at a break. | |
/// </remarks> | |
pub fn JsDiagGetObjectFromHandle(objectHandle: libc::c_uint, | |
handleObject: *mut JsValueRef) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Evaluates an expression on given frame. | |
/// </summary> | |
/// <param name="expression">A null-terminated expression to evaluate.</param> | |
/// <param name="stackFrameIndex">Index of stack frame on which to evaluate the expression.</param> | |
/// <param name="evalResult">Result of evaluation.</param> | |
/// <remarks> | |
/// <para> | |
/// evalResult when evaluating 'this' and return is JsNoError | |
/// { | |
/// "name" : "this", | |
/// "type" : "object", | |
/// "className" : "Object", | |
/// "display" : "{...}", | |
/// "propertyAttributes" : 1, | |
/// "handle" : 18 | |
/// } | |
/// | |
/// evalResult when evaluating a script which throws JavaScript error and return is JsErrorScriptException | |
/// { | |
/// "name" : "a.b.c", | |
/// "type" : "object", | |
/// "className" : "Error", | |
/// "display" : "'a' is undefined", | |
/// "propertyAttributes" : 1, | |
/// "handle" : 18 | |
/// } | |
/// </para> | |
/// </remarks> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, evalResult will contain the result | |
/// The code <c>JsErrorScriptException</c> if evaluate generated a JavaScript exception, evalResult will contain the error details | |
/// Other error code for invalid parameters or API was not called at break | |
/// </returns> | |
/// <remarks> | |
/// The current runtime should be in debug state. This API can only be called when runtime is at a break. | |
/// </remarks> | |
pub fn JsDiagEvaluateUtf8(expression: *const libc::c_char, | |
stackFrameIndex: libc::c_uint, | |
evalResult: *mut JsValueRef) | |
-> JsErrorCode; | |
} | |
pub const JsTTDMoveNone: JsTTDMoveMode = JsTTDMoveMode(0); | |
pub const JsTTDMoveFirstEvent: JsTTDMoveMode = JsTTDMoveMode(1); | |
pub const JsTTDMoveLastEvent: JsTTDMoveMode = JsTTDMoveMode(2); | |
pub const JsTTDMoveKthEvent: JsTTDMoveMode = JsTTDMoveMode(4); | |
pub const JsTTDMoveScanIntervalForContinue: JsTTDMoveMode = JsTTDMoveMode(16); | |
pub const JsTTDMoveBreakOnEntry: JsTTDMoveMode = JsTTDMoveMode(256); | |
impl ::std::ops::BitOr<JsTTDMoveMode> for JsTTDMoveMode { | |
type Output = Self; | |
#[inline] | |
fn bitor(self, other: Self) -> Self { | |
JsTTDMoveMode(self.0 | other.0) | |
} | |
} | |
#[repr(C)] | |
/// ////////////////// | |
/// <summary> | |
/// TimeTravel move options as bit flag enum. | |
/// </summary> | |
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | |
pub struct JsTTDMoveMode(pub u32); | |
/// <summary> | |
/// A handle for URI's that TTD information is written to/read from. | |
/// </summary> | |
#[repr(C)] | |
#[derive(Copy, Clone, Debug)] | |
pub struct JsTTDStreamHandle(pub *mut libc::c_void); | |
impl JsTTDStreamHandle { | |
pub fn new() -> Self { | |
JsTTDStreamHandle(::std::ptr::null_mut()) | |
} | |
} | |
/// <summary> | |
/// TTD API -- may change in future versions: | |
/// Ensure that the location specified for outputting the TTD data is clean. Specifically, ensure that any previous TTD | |
/// in the location has been removed. | |
/// </summary> | |
/// <param name="uriByteLength">The length of the uriBytes array that the host passed in for storing log info.</param> | |
/// <param name="uriBytes">The bytes of the URI that the host passed in for storing log info.</param> | |
pub type JsTTDInitializeForWriteLogStreamCallback = | |
::std::option::Option<unsafe extern "system" fn(uriByteLength: usize, uriBytes: *const byte)>; | |
/// <summary> | |
/// TTD API -- may change in future versions: | |
/// Construct a JsTTDStreamHandle that will be used to read/write the event log portion of the TTD data based on the uri | |
/// provided by JsTTDInitializeUriCallback. | |
/// </summary> | |
/// <remarks> | |
/// <para>Exactly one of read or write will be set to true.</para> | |
/// </remarks> | |
/// <param name="uriByteLength">The length of the uriBytes array that the host passed in for storing log info.</param> | |
/// <param name="uriBytes">The bytes of the URI that the host passed in for storing log info.</param> | |
/// <param name="asciiResourceName">A null terminated ascii string giving a unique name to the resource that the JsTTDStreamHandle will be created for.</param> | |
/// <param name="read">If the handle should be opened for reading.</param> | |
/// <param name="write">If the handle should be opened for writing.</param> | |
/// <returns>A JsTTDStreamHandle opened in read/write mode as specified.</returns> | |
pub type TTDOpenResourceStreamCallback = | |
::std::option::Option<unsafe extern "system" fn(uriByteLength: usize, | |
uriBytes: *const byte, | |
asciiResourceName: *const libc::c_char, | |
read: bool, | |
write: bool, | |
relocatedUri: *mut *mut byte, | |
relocatedUriLength: *mut usize) | |
-> *mut libc::c_void>; | |
/// <summary> | |
/// TTD API -- may change in future versions: | |
/// A callback for reading data from a handle. | |
/// </summary> | |
/// <param name="handle">The JsTTDStreamHandle to read the data from.</param> | |
/// <param name="buff">The buffer to place the data into.</param> | |
/// <param name="size">The max number of bytes that should be read.</param> | |
/// <param name="readCount">The actual number of bytes read and placed in the buffer.</param> | |
/// <returns>true if the read was successful false otherwise.</returns> | |
pub type JsTTDReadBytesFromStreamCallback = | |
::std::option::Option<unsafe extern "system" fn(handle: JsTTDStreamHandle, | |
buff: *mut byte, | |
size: usize, | |
readCount: *mut usize) | |
-> bool>; | |
/// <summary> | |
/// TTD API -- may change in future versions: | |
/// A callback for writing data to a handle. | |
/// </summary> | |
/// <param name="handle">The JsTTDStreamHandle to write the data to.</param> | |
/// <param name="buff">The buffer to copy the data from.</param> | |
/// <param name="size">The max number of bytes that should be written.</param> | |
/// <param name="readCount">The actual number of bytes written to the HANDLE.</param> | |
/// <returns>true if the write was successful false otherwise.</returns> | |
pub type JsTTDWriteBytesToStreamCallback = | |
::std::option::Option<unsafe extern "system" fn(handle: JsTTDStreamHandle, | |
buff: *const byte, | |
size: usize, | |
writtenCount: *mut usize) | |
-> bool>; | |
/// <summary> | |
/// TTD API -- may change in future versions: | |
/// Flush and close the stream represented by the HANDLE as needed. | |
/// </summary> | |
/// <remarks> | |
/// <para>Exactly one of read or write will be set to true.</para> | |
/// </remarks> | |
/// <param name="handle">The JsTTDStreamHandle to close.</param> | |
/// <param name="read">If the handle was opened for reading.</param> | |
/// <param name="write">If the handle was opened for writing.</param> | |
pub type JsTTDFlushAndCloseStreamCallback = | |
::std::option::Option<unsafe extern "system" fn(handle: JsTTDStreamHandle, | |
read: bool, | |
write: bool)>; | |
extern "system" { | |
/// <summary> | |
/// TTD API -- may change in future versions: | |
/// Creates a new runtime in Record Mode. | |
/// </summary> | |
/// <param name="attributes">The attributes of the runtime to be created.</param> | |
/// <param name="infoUri">The uri where the recorded Time-Travel data should be stored.</param> | |
/// <param name="snapInterval">The interval to wait between snapshots (measured in millis).</param> | |
/// <param name="snapHistoryLength">The amount of history to maintain before discarding -- measured in number of snapshots and controls how far back in time a trace can be reversed.</param> | |
/// <param name="writeInitializeFunction">The <c>JsTTDInitializeForWriteLogStreamCallback</c> function for performing any initialization needed prepare uri for storing time travel recording data.</param> | |
/// <param name="openResourceStream">The <c>TTDOpenResourceStreamCallback</c> function for generating a JsTTDStreamHandle to read/write serialized data.</param> | |
/// <param name="readBytesFromStream">The <c>JsTTDReadBytesFromStreamCallback</c> function for reading bytes from a JsTTDStreamHandle.</param> | |
/// <param name="writeBytesToStream">The <c>JsTTDWriteBytesToStreamCallback</c> function for writing bytes to a JsTTDStreamHandle.</param> | |
/// <param name="flushAndCloseStream">The <c>JsTTDFlushAndCloseStreamCallback</c> function for flushing and closing a JsTTDStreamHandle as needed.</param> | |
/// <param name="threadService">The thread service for the runtime. Can be null.</param> | |
/// <param name="runtime">The runtime created.</param> | |
/// <remarks> | |
/// <para>See <c>JsCreateRuntime</c> for additional information.</para> | |
/// </remarks> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsTTDCreateRecordRuntime(attributes: JsRuntimeAttributes, | |
infoUri: *const byte, infoUriCount: usize, | |
snapInterval: usize, | |
snapHistoryLength: usize, | |
writeInitializeFunction: | |
JsTTDInitializeForWriteLogStreamCallback, | |
openResourceStream: | |
TTDOpenResourceStreamCallback, | |
readBytesFromStream: | |
JsTTDReadBytesFromStreamCallback, | |
writeBytesToStream: | |
JsTTDWriteBytesToStreamCallback, | |
flushAndCloseStream: | |
JsTTDFlushAndCloseStreamCallback, | |
threadService: JsThreadServiceCallback, | |
runtime: *mut JsRuntimeHandle) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// TTD API -- may change in future versions: | |
/// Creates a new runtime in Debug Mode. | |
/// </summary> | |
/// <param name="attributes">The attributes of the runtime to be created.</param> | |
/// <param name="infoUri">The uri where the recorded Time-Travel data should be loaded from.</param> | |
/// <param name="enableDebugging">A flag to enable addtional debugging operation support during replay.</param> | |
/// <param name="writeInitializeFunction">The <c>JsTTDInitializeForWriteLogStreamCallback</c> function for performing any initialization needed prepare uri for storing time travel recording data.</param> | |
/// <param name="openResourceStream">The <c>TTDOpenResourceStreamCallback</c> function for generating a JsTTDStreamHandle to read/write serialized data.</param> | |
/// <param name="readBytesFromStream">The <c>JsTTDReadBytesFromStreamCallback</c> function for reading bytes from a JsTTDStreamHandle.</param> | |
/// <param name="writeBytesToStream">The <c>JsTTDWriteBytesToStreamCallback</c> function for writing bytes to a JsTTDStreamHandle.</param> | |
/// <param name="flushAndCloseStream">The <c>JsTTDFlushAndCloseStreamCallback</c> function for flushing and closing a JsTTDStreamHandle as needed.</param> | |
/// <param name="threadService">The thread service for the runtime. Can be null.</param> | |
/// <param name="runtime">The runtime created.</param> | |
/// <remarks> | |
/// <para>See <c>JsCreateRuntime</c> for additional information.</para> | |
/// </remarks> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsTTDCreateReplayRuntime(attributes: JsRuntimeAttributes, | |
infoUri: *const byte, infoUriCount: usize, | |
enableDebugging: bool, | |
writeInitializeFunction: | |
JsTTDInitializeForWriteLogStreamCallback, | |
openResourceStream: | |
TTDOpenResourceStreamCallback, | |
readBytesFromStream: | |
JsTTDReadBytesFromStreamCallback, | |
writeBytesToStream: | |
JsTTDWriteBytesToStreamCallback, | |
flushAndCloseStream: | |
JsTTDFlushAndCloseStreamCallback, | |
threadService: JsThreadServiceCallback, | |
runtime: *mut JsRuntimeHandle) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// TTD API -- may change in future versions: | |
/// Creates a script context that takes the TTD mode from the log or explicitly is not in TTD mode (regular takes mode from currently active script). | |
/// </summary> | |
/// <param name="runtime">The runtime the script context is being created in.</param> | |
/// <param name="useRuntimeTTDMode">Set to true to use runtime TTD mode false to explicitly be non-TTD context.</param> | |
/// <param name="newContext">The created script context.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsTTDCreateContext(runtimeHandle: JsRuntimeHandle, | |
useRuntimeTTDMode: bool, | |
newContext: *mut JsContextRef) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// TTD API -- may change in future versions: | |
/// Notify the time-travel system that a context has been identified as dead by the gc (and is being de-allocated). | |
/// </summary> | |
/// <param name="context">The script context that is now dead.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsTTDNotifyContextDestroy(context: JsContextRef) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// TTD API -- may change in future versions: | |
/// Start Time-Travel Recording. | |
/// </summary> | |
/// <returns>The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise.</returns> | |
pub fn JsTTDStart() -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// TTD API -- may change in future versions: | |
/// Stop Time-Travel Recording. | |
/// </summary> | |
/// <returns>The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise.</returns> | |
pub fn JsTTDStop() -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// TTD API -- may change in future versions: | |
/// Emit Time-Travel Recording. | |
/// </summary> | |
/// <returns>The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise.</returns> | |
pub fn JsTTDEmitRecording() -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// TTD API -- may change in future versions: | |
/// Pause Time-Travel recording before executing code on behalf of debugger or other diagnostic/telemetry. | |
/// </summary> | |
/// <returns>The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise.</returns> | |
pub fn JsTTDPauseTimeTravelBeforeRuntimeOperation() -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// TTD API -- may change in future versions: | |
/// ReStart Time-Travel recording after executing code on behalf of debugger or other diagnostic/telemetry. | |
/// </summary> | |
/// <returns>The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise.</returns> | |
pub fn JsTTDReStartTimeTravelAfterRuntimeOperation() -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// TTD API -- may change in future versions: | |
/// Notify the Js runtime we are at a safe yield point in the event loop (i.e. no locals on the stack and we can proccess as desired). | |
/// </summary> | |
/// <returns>The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise.</returns> | |
pub fn JsTTDNotifyYield() -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// TTD API -- may change in future versions: | |
/// Notify the Js runtime the host is aborting the process and what the status code is. | |
/// </summary> | |
/// <param name="statusCode">The exit status code.</param> | |
/// <returns>The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise.</returns> | |
pub fn JsTTDHostExit(statusCode: libc::c_int) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// TTD API -- may change in future versions: | |
/// Notify the event log that the contents of one buffer have been copied to a second buffer. | |
/// </summary> | |
/// <param name="dst">The buffer that was written into.</param> | |
/// <param name="dstIndex">The first index modified.</param> | |
/// <param name="src">The buffer that was copied from.</param> | |
/// <param name="srcIndex">The first index copied.</param> | |
/// <param name="count">The number of bytes copied.</param> | |
/// <returns>The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise.</returns> | |
pub fn JsTTDRawBufferCopySyncIndirect(dst: JsValueRef, | |
dstIndex: usize, | |
src: JsValueRef, | |
srcIndex: usize, | |
count: usize) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// TTD API -- may change in future versions: | |
/// Notify the event log that the contents of a naked byte* buffer passed to the host have been modified synchronously. | |
/// </summary> | |
/// <param name="buffer">The buffer that was modified.</param> | |
/// <param name="index">The first index modified.</param> | |
/// <param name="count">The number of bytes written.</param> | |
/// <returns>The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise.</returns> | |
pub fn JsTTDRawBufferModifySyncIndirect(buffer: JsValueRef, | |
index: usize, | |
count: usize) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// TTD API -- may change in future versions: | |
/// Get info for notifying the TTD system that a raw buffer it shares with the host has been modified. | |
/// </summary> | |
/// <param name="instance">The array buffer we want to monitor for contents modification.</param> | |
/// <param name="initialModPos">The first position in the buffer that may be modified.</param> | |
/// <returns>The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise.</returns> | |
pub fn JsTTDRawBufferAsyncModificationRegister(instance: JsValueRef, | |
initialModPos: *mut byte) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// TTD API -- may change in future versions: | |
/// Notify the event log that the contents of a naked byte* buffer passed to the host have been modified asynchronously. | |
/// </summary> | |
/// <param name="finalModPos">One past the last modified position in the buffer.</param> | |
/// <returns>The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise.</returns> | |
pub fn JsTTDRawBufferAsyncModifyComplete(finalModPos: *mut byte) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// TTD API -- may change in future versions: | |
/// A check for unimplmented TTD actions in the host. | |
/// This API is a TEMPORARY API while we complete the implementation of TTD support in the Node host and will be deleted once that is complete. | |
/// </summary> | |
/// <param name="msg">The message to print if we should be catching this as a TTD operation.</param> | |
/// <returns>The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise.</returns> | |
pub fn JsTTDCheckAndAssertIfTTDRunning(msg: *const libc::c_char) -> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// TTD API -- may change in future versions: | |
/// Before calling JsTTDMoveToTopLevelEvent (which inflates a snapshot and replays) check to see if we want to reset the script context. | |
/// We reset the script context if the move will require inflating from a different snapshot that the last one. | |
/// </summary> | |
/// <param name="runtimeHandle">The runtime handle that the script is executing in.</param> | |
/// <param name="moveMode">Flags controlling the way the move it performed and how other parameters are interpreted.</param> | |
/// <param name="targetEventTime">The event time we want to move to or -1 if not relevant.</param> | |
/// <param name="targetStartSnapTime">Out parameter with the event time of the snapshot that we should inflate from.</param> | |
/// <param name="targetEndSnapTime">Optional Out parameter with the snapshot time following the event.</param> | |
/// <returns>The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise.</returns> | |
pub fn JsTTDGetSnapTimeTopLevelEventMove(runtimeHandle: JsRuntimeHandle, | |
moveMode: JsTTDMoveMode, | |
targetEventTime: *mut i64, | |
targetStartSnapTime: *mut i64, | |
targetEndSnapTime: *mut i64) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// TTD API -- may change in future versions: | |
/// Get the snapshot interval that bounds the target event time. | |
/// </summary> | |
/// <param name="runtimeHandle">The runtime handle that the script is executing in.</param> | |
/// <param name="targetEventTime">The event time we want to get the interval for.</param> | |
/// <param name="startSnapTime">The snapshot time that comes before the desired event.</param> | |
/// <param name="endSnapTime">The snapshot time that comes after the desired event (-1 if the leg ends before a snapshot appears).</param> | |
/// <returns>The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise.</returns> | |
pub fn JsTTDGetSnapShotBoundInterval(runtimeHandle: JsRuntimeHandle, | |
targetEventTime: i64, | |
startSnapTime: *mut i64, | |
endSnapTime: *mut i64) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// TTD API -- may change in future versions: | |
/// Get the snapshot interval that precedes the one given by currentSnapStartTime (or -1 if there is no such interval). | |
/// </summary> | |
/// <param name="runtimeHandle">The runtime handle that the script is executing in.</param> | |
/// <param name="currentSnapStartTime">The current snapshot interval start time.</param> | |
/// <param name="previousSnapTime">The resulting previous snapshot interval start time or -1 if no such time.</param> | |
/// <returns>The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise.</returns> | |
pub fn JsTTDGetPreviousSnapshotInterval(runtimeHandle: JsRuntimeHandle, | |
currentSnapStartTime: i64, | |
previousSnapTime: *mut i64) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <param name="moveMode">Additional flags for controling how the move is done.</param> | |
/// <param name="newTargetEventTime">The updated target event time set according to the moveMode (-1 if not found).</param> | |
/// <returns>The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise.</returns> | |
pub fn JsTTDPreExecuteSnapShotInterval(runtimeHandle: JsRuntimeHandle, | |
startSnapTime: i64, | |
endSnapTime: i64, | |
moveMode: JsTTDMoveMode, | |
newTargetEventTime: *mut i64) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// TTD API -- may change in future versions: | |
/// Move to the given top-level call event time (assuming JsTTDPrepContextsForTopLevelEventMove) was called previously to reset any script contexts. | |
/// This also computes the ready-to-run snapshot if needed. | |
/// </summary> | |
/// <param name="runtimeHandle">The runtime handle that the script is executing in.</param> | |
/// <param name="moveMode">Additional flags for controling how the move is done.</param> | |
/// <param name="snapshotTime">The event time that we will start executing from to move to the given target time.</param> | |
/// <param name="eventTime">The event that we want to move to.</param> | |
/// <returns>The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise.</returns> | |
pub fn JsTTDMoveToTopLevelEvent(runtimeHandle: JsRuntimeHandle, | |
moveMode: JsTTDMoveMode, | |
snapshotTime: i64, | |
eventTime: i64) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// TTD API -- may change in future versions: | |
/// Execute from the current point in the log to the end returning the error code. | |
/// </summary> | |
/// <param name="moveMode">Additional flags for controling how the move is done.</param> | |
/// <param name="rootEventTime">The event time that we should move to next or notification (-1) that replay has ended.</param> | |
/// <returns> | |
/// If the debugger requested an abort the code is JsNoError -- rootEventTime is the target event time we need to move to and re - execute from. | |
/// If we aborted at the end of the replay log the code is JsNoError -- rootEventTime is -1. | |
/// If there was an unhandled script exception the code is JsErrorCategoryScript. | |
/// </returns> | |
pub fn JsTTDReplayExecution(moveMode: *mut JsTTDMoveMode, | |
rootEventTime: *mut i64) | |
-> JsErrorCode; | |
} | |
#[repr(C)] | |
#[derive(Copy, Clone, Debug)] | |
pub struct JsModuleRecord(pub *mut libc::c_void); | |
impl JsModuleRecord { | |
pub fn new() -> Self { | |
JsModuleRecord(::std::ptr::null_mut()) | |
} | |
} | |
#[repr(u32)] | |
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | |
pub enum JsParseModuleSourceFlags { | |
DataIsUTF16LE = 0, | |
DataIsUTF8 = 1, | |
} | |
#[repr(u32)] | |
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | |
pub enum JsModuleHostInfoKind { | |
Exception = 1, | |
HostDefined = 2, | |
NotifyModuleReadyCallback = 3, | |
FetchImportedModuleCallback = 4, | |
} | |
extern "system" { | |
/// <summary> | |
/// Initialize a ModuleRecord from host | |
/// </summary> | |
/// <remarks> | |
/// Bootstrap the module loading process by creating a new module record. | |
/// </remarks> | |
/// <param name="referencingModule">The referencingModule as in HostResolveImportedModule (15.2.1.17). nullptr if this is the top level module.</param> | |
/// <param name="normalizedSpecifier">The host normalized specifier. This is the key to a unique ModuleRecord.</param> | |
/// <param name="moduleRecord">The new ModuleRecord created. The host should not try to call this API twice with the same normalizedSpecifier. | |
/// chakra will return an existing ModuleRecord if the specifier was passed in before.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsInitializeModuleRecord(referencingModule: JsModuleRecord, | |
normalizedSpecifier: JsValueRef, | |
moduleRecord: *mut JsModuleRecord) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Parse the module source | |
/// </summary> | |
/// <remarks> | |
/// This is basically ParseModule operation in ES6 spec. It is slightly different in that the ModuleRecord was initialized earlier, and passed in as an argument. | |
/// </remarks> | |
/// <param name="requestModule">The ModuleRecord that holds the parse tree of the source code.</param> | |
/// <param name="sourceContext">A cookie identifying the script that can be used by debuggable script contexts.</param> | |
/// <param name="script">The source script to be parsed, but not executed in this code.</param> | |
/// <param name="scriptLength">The source length of sourceText. The input might contain embedded null.</param> | |
/// <param name="sourceFlag">The type of the source code passed in. It could be UNICODE or utf8 at this time.</param> | |
/// <param name="exceptionValueRef">The error object if there is parse error.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsParseModuleSource(requestModule: JsModuleRecord, | |
sourceContext: JsSourceContext, | |
script: *mut BYTE, | |
scriptLength: libc::c_uint, | |
sourceFlag: JsParseModuleSourceFlags, | |
exceptionValueRef: *mut JsValueRef) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Execute module code. | |
/// </summary> | |
/// <remarks> | |
/// This method implements 15.2.1.1.6.5, "ModuleEvaluation" concrete method. | |
/// When this methid is called, the chakra engine should have notified the host that the module and all its dependent are ready to be executed. | |
/// One moduleRecord will be executed only once. Additional execution call on the same moduleRecord will fail. | |
/// </remarks> | |
/// <param name="requestModule">The module to be executed.</param> | |
/// <param name="result">The return value of the module.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsModuleEvaluation(requestModule: JsModuleRecord, | |
result: *mut JsValueRef) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Set the host info for the specified module. | |
/// </summary> | |
/// <param name="requestModule">The request module.</param> | |
/// <param name="moduleHostInfo">The type of host info to be set.</param> | |
/// <param name="hostInfo">The host info to be set.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsSetModuleHostInfo(requestModule: JsModuleRecord, | |
moduleHostInfo: JsModuleHostInfoKind, | |
hostInfo: *mut libc::c_void) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Retrieve the host info for the specified module. | |
/// </summary> | |
/// <param name="requestModule">The request module.</param> | |
/// <param name="moduleHostInfo">The type of host info to get.</param> | |
/// <param name="hostInfo">The host info to be retrieved.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsGetModuleHostInfo(requestModule: JsModuleRecord, | |
moduleHostInfo: JsModuleHostInfoKind, | |
hostInfo: *mut *mut libc::c_void) | |
-> JsErrorCode; | |
} | |
/// <summary> | |
/// Called by the runtime to load the source code of the serialized script. | |
/// </summary> | |
/// <param name="sourceContext">The context passed to Js[Parse|Run]SerializedScriptCallback</param> | |
/// <param name="script">The script returned.</param> | |
/// <returns> | |
/// true if the operation succeeded, false otherwise. | |
/// </returns> | |
pub type JsSerializedLoadScriptCallback = | |
::std::option::Option<unsafe extern "system" fn(sourceContext: JsSourceContext, | |
value: *mut JsValueRef, | |
parseAttributes: | |
*mut JsParseScriptAttributes) | |
-> bool>; | |
extern "system" { | |
/// <summary> | |
/// Create JavascriptString variable from C string | |
/// </summary> | |
/// <remarks> | |
/// <para> | |
/// C string is expected to be ASCII | |
/// </para> | |
/// </remarks> | |
/// <param name="content">Pointer to string memory.</param> | |
/// <param name="length">Number of bytes within the string</param> | |
/// <param name="value">JsValueRef representing the JavascriptString</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsCreateString(content: *const libc::c_char, | |
length: usize, | |
value: *mut JsValueRef) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Create JavascriptString variable from Utf8 string | |
/// </summary> | |
/// <remarks> | |
/// <para> | |
/// Input string can be either ASCII or Utf8 | |
/// </para> | |
/// </remarks> | |
/// <param name="content">Pointer to string memory.</param> | |
/// <param name="length">Number of bytes within the string</param> | |
/// <param name="value">JsValueRef representing the JavascriptString</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsCreateStringUtf8(content: *const u8, | |
length: usize, | |
value: *mut JsValueRef) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Create JavascriptString variable from Utf16 string | |
/// </summary> | |
/// <remarks> | |
/// <para> | |
/// Expects Utf16 string | |
/// </para> | |
/// </remarks> | |
/// <param name="content">Pointer to string memory.</param> | |
/// <param name="length">Number of characters within the string</param> | |
/// <param name="value">JsValueRef representing the JavascriptString</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsCreateStringUtf16(content: *const u16, | |
length: usize, | |
value: *mut JsValueRef) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Write JavascriptString value into C string buffer | |
/// </summary> | |
/// <remarks> | |
/// <para> | |
/// When size of the `buffer` is unknown, | |
/// `buffer` argument can be nullptr. | |
/// In that case, `written` argument will return the length needed. | |
/// </para> | |
/// <para> | |
/// when start is out of range or < 0, returns JsErrorInvalidArgument | |
/// and `written` will be equal to 0. | |
/// If calculated length is 0 (It can be due to string length or `start` | |
/// and length combination), then `written` will be equal to 0 and call | |
/// returns JsNoError | |
/// </para> | |
/// </remarks> | |
/// <param name="value">JavascriptString value</param> | |
/// <param name="start">start offset of buffer</param> | |
/// <param name="length">length to be written</param> | |
/// <param name="buffer">Pointer to buffer</param> | |
/// <param name="written">Total number of characters written</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsCopyString(value: JsValueRef, | |
start: libc::c_int, | |
length: libc::c_int, | |
buffer: *mut libc::c_char, | |
written: *mut usize) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Write JavascriptString value into Utf8 string buffer | |
/// </summary> | |
/// <remarks> | |
/// <para> | |
/// When size of the `buffer` is unknown, | |
/// `buffer` argument can be nullptr. | |
/// In that case, `written` argument will return the length needed. | |
/// </para> | |
/// </remarks> | |
/// <param name="value">JavascriptString value</param> | |
/// <param name="buffer">Pointer to buffer</param> | |
/// <param name="bufferSize">Buffer size</param> | |
/// <param name="written">Total number of characters written</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsCopyStringUtf8(value: JsValueRef, | |
buffer: *mut u8, | |
bufferSize: usize, | |
written: *mut usize) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Write string value into Utf16 string buffer | |
/// </summary> | |
/// <remarks> | |
/// <para> | |
/// When size of the `buffer` is unknown, | |
/// `buffer` argument can be nullptr. | |
/// In that case, `written` argument will return the length needed. | |
/// </para> | |
/// <para> | |
/// when start is out of range or < 0, returns JsErrorInvalidArgument | |
/// and `written` will be equal to 0. | |
/// If calculated length is 0 (It can be due to string length or `start` | |
/// and length combination), then `written` will be equal to 0 and call | |
/// returns JsNoError | |
/// </para> | |
/// </remarks> | |
/// <param name="value">JavascriptString value</param> | |
/// <param name="start">start offset of buffer</param> | |
/// <param name="length">length to be written</param> | |
/// <param name="buffer">Pointer to buffer</param> | |
/// <param name="written">Total number of characters written</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsCopyStringUtf16(value: JsValueRef, | |
start: libc::c_int, | |
length: libc::c_int, | |
buffer: *mut u16, | |
written: *mut usize) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Parses a script and returns a function representing the script. | |
/// </summary> | |
/// <remarks> | |
/// <para> | |
/// Requires an active script context. | |
/// </para> | |
/// <para> | |
/// Script source can be either JavascriptString or JavascriptExternalArrayBuffer. | |
/// In case it is an ExternalArrayBuffer, and the encoding of the buffer is Utf16, | |
/// JsParseScriptAttributeArrayBufferIsUtf16Encoded is expected on parseAttributes. | |
/// </para> | |
/// <para> | |
/// Use JavascriptExternalArrayBuffer with Utf8/ASCII script source | |
/// for better performance and smaller memory footprint. | |
/// </para> | |
/// </remarks> | |
/// <param name="script">The script to run.</param> | |
/// <param name="sourceContext"> | |
/// A cookie identifying the script that can be used by debuggable script contexts. | |
/// </param> | |
/// <param name="sourceUrl">The location the script came from.</param> | |
/// <param name="parseAttributes">Attribute mask for parsing the script</param> | |
/// <param name="result">The result of the compiled script.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsParse(script: JsValueRef, | |
sourceContext: JsSourceContext, | |
sourceUrl: JsValueRef, | |
parseAttributes: JsParseScriptAttributes, | |
result: *mut JsValueRef) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Executes a script. | |
/// </summary> | |
/// <remarks> | |
/// <para> | |
/// Requires an active script context. | |
/// </para> | |
/// <para> | |
/// Script source can be either JavascriptString or JavascriptExternalArrayBuffer. | |
/// In case it is an ExternalArrayBuffer, and the encoding of the buffer is Utf16, | |
/// JsParseScriptAttributeArrayBufferIsUtf16Encoded is expected on parseAttributes. | |
/// </para> | |
/// <para> | |
/// Use JavascriptExternalArrayBuffer with Utf8/ASCII script source | |
/// for better performance and smaller memory footprint. | |
/// </para> | |
/// </remarks> | |
/// <param name="script">The script to run.</param> | |
/// <param name="sourceContext"> | |
/// A cookie identifying the script that can be used by debuggable script contexts. | |
/// </param> | |
/// <param name="sourceUrl">The location the script came from</param> | |
/// <param name="parseAttributes">Attribute mask for parsing the script</param> | |
/// <param name="result">The result of the script, if any. This parameter can be null.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsRun(script: JsValueRef, | |
sourceContext: JsSourceContext, | |
sourceUrl: JsValueRef, | |
parseAttributes: JsParseScriptAttributes, | |
result: *mut JsValueRef) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Creates the property ID associated with the name. | |
/// </summary> | |
/// <remarks> | |
/// <para> | |
/// Property IDs are specific to a context and cannot be used across contexts. | |
/// </para> | |
/// <para> | |
/// Requires an active script context. | |
/// </para> | |
/// </remarks> | |
/// <param name="name"> | |
/// The name of the property ID to get or create. The name may consist of only digits. | |
/// The string is expected to be ASCII / utf8 encoded. | |
/// </param> | |
/// <param name="length">length of the name in bytes</param> | |
/// <param name="propertyId">The property ID in this runtime for the given name.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsCreatePropertyIdUtf8(name: *const libc::c_char, | |
length: usize, | |
propertyId: *mut JsPropertyIdRef) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Copies the name associated with the property ID into a buffer. | |
/// </summary> | |
/// <remarks> | |
/// <para> | |
/// Requires an active script context. | |
/// </para> | |
/// <para> | |
/// When size of the `buffer` is unknown, | |
/// `buffer` argument can be nullptr. | |
/// `length` argument will return the size needed. | |
/// </para> | |
/// </remarks> | |
/// <param name="propertyId">The property ID to get the name of.</param> | |
/// <param name="buffer">The buffer holding the name associated with the property ID, encoded as utf8</param> | |
/// <param name="bufferSize">Size of the buffer.</param> | |
/// <param name="written">Total number of characters written or to be written</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsCopyPropertyIdUtf8(propertyId: JsPropertyIdRef, | |
buffer: *mut u8, | |
bufferSize: usize, | |
length: *mut usize) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Serializes a parsed script to a buffer than can be reused. | |
/// </summary> | |
/// <remarks> | |
/// <para> | |
/// <c>JsSerializeScript</c> parses a script and then stores the parsed form of the script in a | |
/// runtime-independent format. The serialized script then can be deserialized in any | |
/// runtime without requiring the script to be re-parsed. | |
/// </para> | |
/// <para> | |
/// Requires an active script context. | |
/// </para> | |
/// <para> | |
/// Script source can be either JavascriptString or JavascriptExternalArrayBuffer. | |
/// In case it is an ExternalArrayBuffer, and the encoding of the buffer is Utf16, | |
/// JsParseScriptAttributeArrayBufferIsUtf16Encoded is expected on parseAttributes. | |
/// </para> | |
/// <para> | |
/// Use JavascriptExternalArrayBuffer with Utf8/ASCII script source | |
/// for better performance and smaller memory footprint. | |
/// </para> | |
/// </remarks> | |
/// <param name="script">The script to serialize</param> | |
/// <param name="buffer">The buffer to put the serialized script into. Can be null.</param> | |
/// <param name="bufferSize"> | |
/// On entry, the size of the buffer, in bytes; on exit, the size of the buffer, in bytes, | |
/// required to hold the serialized script. | |
/// </param> | |
/// <param name="parseAttributes">Encoding for the script.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsSerialize(script: JsValueRef, | |
buffer: *mut BYTE, | |
bufferSize: *mut libc::c_uint, | |
parseAttributes: JsParseScriptAttributes) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Parses a serialized script and returns a function representing the script. | |
/// Provides the ability to lazy load the script source only if/when it is needed. | |
/// </summary> | |
/// <remarks> | |
/// <para> | |
/// Requires an active script context. | |
/// </para> | |
/// </remarks> | |
/// <param name="buffer">The serialized script.</param> | |
/// <param name="scriptLoadCallback"> | |
/// Callback called when the source code of the script needs to be loaded. | |
/// This is an optional parameter, set to null if not needed. | |
/// </param> | |
/// <param name="sourceContext"> | |
/// A cookie identifying the script that can be used by debuggable script contexts. | |
/// This context will passed into scriptLoadCallback. | |
/// </param> | |
/// <param name="sourceUrl">The location the script came from.</param> | |
/// <param name="result">A function representing the script code.</param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsParseSerialized(buffer: *mut BYTE, | |
scriptLoadCallback: JsSerializedLoadScriptCallback, | |
sourceContext: JsSourceContext, | |
sourceUrl: JsValueRef, | |
result: *mut JsValueRef) | |
-> JsErrorCode; | |
} | |
extern "system" { | |
/// <summary> | |
/// Runs a serialized script. | |
/// Provides the ability to lazy load the script source only if/when it is needed. | |
/// </summary> | |
/// <remarks> | |
/// <para> | |
/// Requires an active script context. | |
/// </para> | |
/// <para> | |
/// The runtime will hold on to the buffer until all instances of any functions created from | |
/// the buffer are garbage collected. | |
/// </para> | |
/// </remarks> | |
/// <param name="buffer">The serialized script.</param> | |
/// <param name="scriptLoadCallback">Callback called when the source code of the script needs to be loaded.</param> | |
/// <param name="sourceContext"> | |
/// A cookie identifying the script that can be used by debuggable script contexts. | |
/// This context will passed into scriptLoadCallback. | |
/// </param> | |
/// <param name="sourceUrl">The location the script came from.</param> | |
/// <param name="result"> | |
/// The result of running the script, if any. This parameter can be null. | |
/// </param> | |
/// <returns> | |
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise. | |
/// </returns> | |
pub fn JsRunSerialized(buffer: *mut BYTE, | |
scriptLoadCallback: JsSerializedLoadScriptCallback, | |
sourceContext: JsSourceContext, | |
sourceUrl: JsValueRef, | |
result: *mut JsValueRef) | |
-> JsErrorCode; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment