JSObjectRef onError) :
m_onSuccess(NULL),
m_onError(NULL),
+ m_object(NULL),
m_context(context)
{
LogDebug("entered");
if (m_onError) {
JSValueUnprotect(m_context, m_onError);
}
+
+ if (m_object) {
+ JSValueUnprotect(m_context, m_object);
+ }
}
void JSCallbackManager::setOnSuccess(JSValueRef onSuccess)
{
LogDebug("entered");
- if (onSuccess) {
- if (m_onSuccess != NULL) {
- JSValueUnprotect(m_context, m_onSuccess);
- }
+ if (m_onSuccess != NULL) {
+ JSValueUnprotect(m_context, m_onSuccess);
+ }
+ if (onSuccess) {
m_onSuccess = JSValueToObject(m_context, onSuccess, NULL);
+ } else {
+ m_onSuccess = NULL;
+ }
- if (m_onSuccess != NULL) {
- JSValueProtect(m_context, m_onSuccess);
- }
+ if (m_onSuccess != NULL) {
+ JSValueProtect(m_context, m_onSuccess);
}
}
void JSCallbackManager::setOnError(JSValueRef onError)
{
LogDebug("entered");
- if (onError) {
- if (m_onError != NULL) {
- JSValueUnprotect(m_context, m_onError);
- }
+ if (m_onError != NULL) {
+ JSValueUnprotect(m_context, m_onError);
+ }
+ if (onError) {
m_onError = JSValueToObject(m_context, onError, NULL);
+ } else {
+ m_onError = NULL;
+ }
- if (m_onError != NULL) {
- JSValueProtect(m_context, m_onError);
- }
+ if (m_onError != NULL) {
+ JSValueProtect(m_context, m_onError);
}
}
return m_onError;
}
+void JSCallbackManager::setObject(JSObjectRef object)
+{
+ LogDebug("entered");
+ if (m_object != NULL) {
+ JSValueUnprotect(m_context, m_object);
+ }
+
+ m_object = object;
+
+ if (m_object != NULL) {
+ JSValueProtect(m_context, m_object);
+ }
+}
+
+JSObjectRef JSCallbackManager::getObject() const
+{
+ LogDebug("entered");
+ return m_object;
+}
+
void JSCallbackManager::setContext(JSContextRef context)
{
LogDebug("entered");