jsbindings/jsbindings.cpp
/**
 * @brief Callback invoked from JS to remove an event listener
 *
 * @param[in] context        JS execution context
 * @param[in] function       JSObject that is the function being called
 * @param[in] thisObject     JSObject that is the 'this' variable in the function's scope
 * @param[in] argumentCount  Number of args
 * @param[in] arguments[]    JSValue array of args
 * @param[out] exception     Pointer to a JSValueRef in which to return an exception, if any
 *
 * @retval JSValue that is the function's return value
 */


@retval JSValue that is the function's return value
@retval JSValue that is the function ' s return value
static JSValueRef AAMP_removeEventListener(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef *exception)
{
	LOG("[AAMP_JS] %s()", __FUNCTION__);
	AAMP_JS* pAAMP = (AAMP_JS*)JSObjectGetPrivate(thisObject); 
	if (pAAMP == NULL)
	{
		ERROR("[AAMP_JS] %s() Error: JSObjectGetPrivate returned NULL!", __FUNCTION__);
		*exception = aamp_GetException(context, AAMPJS_MISSING_OBJECT, "Can only call AAMP.removeEventListener on instances of AAMP");
		return JSValueMakeUndefined(context);
	}
	if (argumentCount >= 2)
	{
		JSObjectRef callbackObj = JSValueToObject(context, arguments[1], NULL);
		if (callbackObj != NULL && JSObjectIsFunction(context, callbackObj))
		{
			char* type = aamp_JSValueToCString(context, arguments[0], NULL);
			AAMPEventType eventType = aamp_getEventTypeFromName(type);
			LOG("[AAMP_JS] %s() eventType='%s', %d", __FUNCTION__, type, eventType);
			if ((eventType >= 0) && (eventType < AAMP_MAX_NUM_EVENTS))
			{
				AAMP_JSListener::RemoveEventListener(pAAMP, eventType, callbackObj);
			}
			delete[] type;
		}
		else
		{
			ERROR("[AAMP_JS] %s() InvalidArgument: callbackObj=%p, JSObjectIsFunction(context, callbackObj)=%d", __FUNCTION__, callbackObj, JSObjectIsFunction(context, callbackObj));
			*exception = aamp_GetException(context, AAMPJS_INVALID_ARGUMENT, "Failed to execute 'AAMP.removeEventListener' - parameter 2 is not a function");
		}
	}
	else
	{
		ERROR("[AAMP_JS] %s() InvalidArgument: argumentCount=%d, expected: 2", __FUNCTION__, argumentCount);
		*exception = aamp_GetException(context, AAMPJS_INVALID_ARGUMENT, "Failed to execute 'AAMP.removeEventListener' - 2 arguments required.");
	}
	return JSValueMakeUndefined(context);
}
static JSValueRef AAMP_removeEventListener ( JSContextRef context , JSObjectRef function , JSObjectRef thisObject , size_t argumentCount , const JSValueRef arguments [ ] , JSValueRef * exception ) { LOG ( " " , __FUNCTION__ ) ; AAMP_JS * pAAMP = ( AAMP_JS * ) JSObjectGetPrivate ( thisObject ) ; if ( pAAMP == NULL ) { ERROR ( " " , __FUNCTION__ ) ; * exception = aamp_GetException ( context , AAMPJS_MISSING_OBJECT , " " ) ; return JSValueMakeUndefined ( context ) ; } if ( argumentCount >= 2 ) { JSObjectRef callbackObj = JSValueToObject ( context , arguments [ 1 ] , NULL ) ; if ( callbackObj != NULL && JSObjectIsFunction ( context , callbackObj ) ) { char * type = aamp_JSValueToCString ( context , arguments [ 0 ] , NULL ) ; AAMPEventType eventType = aamp_getEventTypeFromName ( type ) ; LOG ( " " , __FUNCTION__ , type , eventType ) ; if ( ( eventType >= 0 ) && ( eventType < AAMP_MAX_NUM_EVENTS ) ) { AAMP_JSListener :: RemoveEventListener ( pAAMP , eventType , callbackObj ) ; } delete [ ] type ; } else { ERROR ( " " , __FUNCTION__ , callbackObj , JSObjectIsFunction ( context , callbackObj ) ) ; * exception = aamp_GetException ( context , AAMPJS_INVALID_ARGUMENT , " " ) ; } } else { ERROR ( " " , __FUNCTION__ , argumentCount ) ; * exception = aamp_GetException ( context , AAMPJS_INVALID_ARGUMENT , " " ) ; } return JSValueMakeUndefined ( context ) ; }
@brief Callback invoked from JS to remove an event listener
 @param[in] context        JS execution context
 @param[in] function       JSObject that is the function being called
 @param[in] thisObject     JSObject that is the 'this' variable in the function's scope
 @param[in] argumentCount  Number of args
 @param[in] arguments[]    JSValue array of args
 @param[out] exception     Pointer to a JSValueRef in which to return an exception, if any
@brief Callback invoked from JS to remove an event listener @param [ in ] context JS execution context @param [ in ] function JSObject that is the function being called @param [ in ] thisObject JSObject that is the ' this ' variable in the function ' s scope @param [ in ] argumentCount Number of args @param [ in ] arguments [] JSValue array of args @param [ out ] exception Pointer to a JSValueRef in which to return an exception if any