mCallbackUserData = new MultiCallbackUserData(globalCtx);
// onprogress
- JSValueRef onprogress = JSUtil::getProperty(globalCtx, object, "onprogress");
- if (JSValueIsUndefined(globalCtx, onprogress)) {
- onprogress = NULL;
- } else {
- JSObjectRef cbObj = JSValueToObject(globalCtx, onprogress, NULL);
- if (JSObjectIsFunction(globalCtx, cbObj)) {
+ JSStringRef onprogress = JSStringCreateWithUTF8CString("onprogress");
+ bool has_onprogress = JSObjectHasProperty(globalCtx, object, onprogress);
+ JSStringRelease(onprogress);
+ if (has_onprogress) {
+ JSObjectRef cbObj = JSUtil::JSValueToObject(globalCtx, JSUtil::getProperty(globalCtx, object, "onprogress"));
+ if( JSObjectIsFunction(globalCtx, cbObj) ){
mCallbackUserData->setCallback("onprogress", cbObj);
} else {
throw TypeMismatchException("onprogress is not a callback function.");
}
// onpaused
- JSValueRef onpaused = JSUtil::getProperty(globalCtx, object, "onpaused");
- if (JSValueIsUndefined(globalCtx, onpaused)) {
- onpaused = NULL;
- } else {
- JSObjectRef cbObj = JSValueToObject(globalCtx, onpaused, NULL);
- if (JSObjectIsFunction(globalCtx, cbObj)) {
+ JSStringRef onpaused = JSStringCreateWithUTF8CString("onpaused");
+ bool has_onpaused = JSObjectHasProperty(globalCtx, object, onpaused);
+ JSStringRelease(onpaused);
+ if (has_onpaused) {
+ JSObjectRef cbObj = JSUtil::JSValueToObject(globalCtx, JSUtil::getProperty(globalCtx, object, "onpaused"));
+ if( JSObjectIsFunction(globalCtx, cbObj) ){
mCallbackUserData->setCallback("onpaused", cbObj);
} else {
throw TypeMismatchException("onpaused is not a callback function.");
}
// oncanceled
- JSValueRef oncanceled = JSUtil::getProperty(globalCtx, object, "oncanceled");
- if (JSValueIsUndefined(globalCtx, oncanceled)) {
- oncanceled = NULL;
- } else {
- JSObjectRef cbObj = JSValueToObject(globalCtx, oncanceled, NULL);
- if (JSObjectIsFunction(globalCtx, cbObj)) {
+ JSStringRef oncanceled = JSStringCreateWithUTF8CString("oncanceled");
+ bool has_oncanceled = JSObjectHasProperty(globalCtx, object, oncanceled);
+ JSStringRelease(oncanceled);
+ if (has_oncanceled) {
+ JSObjectRef cbObj = JSUtil::JSValueToObject(globalCtx, JSUtil::getProperty(globalCtx, object, "oncanceled"));
+ if( JSObjectIsFunction(globalCtx, cbObj) ){
mCallbackUserData->setCallback("oncanceled", cbObj);
} else {
throw TypeMismatchException("oncanceled is not a callback function.");
}
// oncompleted
- JSValueRef oncompleted = JSUtil::getProperty(globalCtx, object, "oncompleted");
- if (JSValueIsUndefined(globalCtx, oncompleted)) {
- oncompleted = NULL;
- } else {
- JSObjectRef cbObj = JSValueToObject(globalCtx, oncompleted, NULL);
- if (JSObjectIsFunction(globalCtx, cbObj)) {
+ JSStringRef oncompleted = JSStringCreateWithUTF8CString("oncompleted");
+ bool has_oncompleted = JSObjectHasProperty(globalCtx, object, oncompleted);
+ JSStringRelease(oncompleted);
+ if (has_oncompleted) {
+ JSObjectRef cbObj = JSUtil::JSValueToObject(globalCtx, JSUtil::getProperty(globalCtx, object, "oncompleted"));
+ if( JSObjectIsFunction(globalCtx, cbObj) ){
mCallbackUserData->setCallback("oncompleted", cbObj);
} else {
throw TypeMismatchException("oncompleted is not a callback function.");
}
// onfailed
- JSValueRef onfailed = JSUtil::getProperty(globalCtx, object, "onfailed");
- if (JSValueIsUndefined(globalCtx, onfailed)) {
- onfailed = NULL;
- } else {
- JSObjectRef cbObj = JSValueToObject(globalCtx, onfailed, NULL);
- if (JSObjectIsFunction(globalCtx, cbObj)) {
+ JSStringRef onfailed = JSStringCreateWithUTF8CString("onfailed");
+ bool has_onfailed = JSObjectHasProperty(globalCtx, object, onfailed);
+ JSStringRelease(onfailed);
+ if (has_onfailed) {
+ JSObjectRef cbObj = JSUtil::JSValueToObject(globalCtx, JSUtil::getProperty(globalCtx, object, "onfailed"));
+ if( JSObjectIsFunction(globalCtx, cbObj) ){
mCallbackUserData->setCallback("onfailed", cbObj);
} else {
throw TypeMismatchException("onfailed is not a callback function.");