Skip to content
Permalink
Browse files

add JsIsCallable API

  • Loading branch information...
MikeHolman committed Mar 11, 2019
1 parent a247f4f commit 7044f7807a18b1df1323445123b4465134b45e9c
Showing with 33 additions and 0 deletions.
  1. +16 −0 lib/Jsrt/ChakraCore.h
  2. +16 −0 lib/Jsrt/Core/JsrtCore.cpp
  3. +1 −0 lib/Jsrt/JsrtCommonExports.inc
@@ -1202,6 +1202,22 @@ JsGetErrorPrototype(_Out_ JsValueRef * result);
CHAKRA_API
JsGetIteratorPrototype(_Out_ JsValueRef * result);

/// <summary>
/// Returns a value that indicates whether an object is callable.
/// </summary>
/// <remarks>
/// Requires an active script context.
/// </remarks>
/// <param name="object">The object to test.</param>
/// <param name="isConstructor">If the object is callable, <c>true</c>, <c>false</c> otherwise.</param>
/// <returns>
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise.
/// </returns>
CHAKRA_API
JsIsCallable(
_In_ JsValueRef object,
_Out_ bool *isCallable);

/// <summary>
/// Returns a value that indicates whether an object is a constructor.
/// </summary>
@@ -1392,6 +1392,22 @@ CHAKRA_API JsAllocRawData(_In_ JsRuntimeHandle runtimeHandle, _In_ size_t sizeIn
});
}

CHAKRA_API JsIsCallable(_In_ JsValueRef object, _Out_ bool *isCallable)
{
return ContextAPIWrapper<JSRT_MAYBE_TRUE>([&](Js::ScriptContext *scriptContext, TTDRecorder& _actionEntryPopper) -> JsErrorCode {
PERFORM_JSRT_TTD_RECORD_ACTION_NOT_IMPLEMENTED(scriptContext);
VALIDATE_INCOMING_OBJECT(object, scriptContext);
PARAM_NOT_NULL(isCallable);

Js::RecyclableObject * instance = Js::VarTo<Js::RecyclableObject>(object);
AssertMsg(scriptContext->GetThreadContext()->IsScriptActive(), "Caller is expected to be under ContextAPIWrapper!");

*isCallable = Js::JavascriptConversion::IsCallable(instance);

return JsNoError;
});
}

CHAKRA_API JsIsConstructor(_In_ JsValueRef object, _Out_ bool *isConstructor)
{
return ContextAPIWrapper<JSRT_MAYBE_TRUE>([&](Js::ScriptContext *scriptContext, TTDRecorder& _actionEntryPopper) -> JsErrorCode {
@@ -136,6 +136,7 @@
JsGetWeakReferenceValue
JsHasOwnProperty
JsHasOwnItem
JsIsCallable
JsIsConstructor
JsObjectDefineProperty
JsObjectDefinePropertyFull

0 comments on commit 7044f78

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.