void GeoLocation::Run(const String& command) { if(!command.IsEmpty()) { Uri commandUri; commandUri.SetUri(command); String method = commandUri.GetHost(); StringTokenizer strTok(commandUri.GetPath(), L"/"); if(strTok.GetTokenCount() > 1) { strTok.GetNextToken(callbackId); AppLogDebug("Method %S, CallbackId: %S", method.GetPointer(), callbackId.GetPointer()); } AppLogDebug("Method %S, Callback: %S", method.GetPointer(), callbackId.GetPointer()); // used to determine callback ID if(method == L"com.phonegap.Geolocation.watchPosition" && !callbackId.IsEmpty() && !IsWatching()) { AppLogDebug("watching position..."); StartWatching(); } if(method == L"com.phonegap.Geolocation.stop" && IsWatching()) { AppLogDebug("stop watching position..."); StopWatching(); } if(method == L"com.phonegap.Geolocation.getCurrentPosition" && !callbackId.IsEmpty() && !IsWatching()) { AppLogDebug("getting current position..."); GetLastKnownLocation(); } AppLogDebug("GeoLocation command %S completed", command.GetPointer()); } }
void Registry::Delete(Object const &object) { #ifdef KAI_DEBUG if (IsWatching(object)) KAI_TRACE() << object.GetHandle(); #endif Delete(object.GetHandle()); }
Object Registry::GetObject(Handle handle) const { #ifdef KAI_DEBUG if (IsWatching(handle) && gc_trace_level > 1) KAI_TRACE() << handle; #endif if (handle == 0) return Object(); Instances::const_iterator A = instances.find(handle); if (A == instances.end()) return Object(); return *A->second; }
void Registry::DestroyObject(Handle handle, bool force) { bool succeeded = false; KAI_TRY { Instances::iterator iter = instances.find(handle); if (iter == instances.end()) { #ifdef KAI_DEBUG if (IsWatching(handle)) { KAI_TRACE() << handle << ": doesn't exist, not deleted"; } #endif return; } StorageBase &base = *iter->second; assert(base.GetHandle() == handle); if (!base.IsManaged() && !force) { #ifdef KAI_DEBUG if (IsWatching(handle)) KAI_TRACE() << handle << ": " << base << " is not managed, not deleted"; #endif return; } #ifdef KAI_DEBUG bool trace = gc_trace_level > 3; trace = trace || IsWatching(base); if (trace) { KAI_TRY { KAI_TRACE() << handle; } KAI_CATCH_ALL() { } } #endif #ifdef KAI_USE_TRICOLOR // when using tri-color GC, objects are always deleted when they are destroyed if (!base.GetClass()->Destroy(base) && !force) { base.SetColor(ObjectColor::Grey); return; } #endif base.GetClass()->Delete(base); instances.erase(iter); RetainedObjects::iterator retained = retained_objects.find(handle); if (retained != retained_objects.end()) { retained_objects.erase(retained); } succeeded = true; } KAI_CATCH(Exception::Base, E) { KAI_TRACE() << "\n\t" << E.ToString(); } KAI_CATCH(std::exception, E) { KAI_TRACE() << "std::exception: " << E.what(); } KAI_CATCH_ALL() { } if (!succeeded) { KAI_TRACE() << "*** AWESOMELY BAD EXCEPTION deleting object ***"; Instances::iterator iter = instances.find(handle); if (iter != instances.end()) { // this leaks and has other *TERRIBLE* consequences but it is the best we can do to keep afloat instances.erase(iter); } } }
void Registry::DestroyObject(Handle handle, bool force) { bool succeeded = false; KAI_TRY { Instances::iterator iter = instances.find(handle); if (iter == instances.end()) { #ifdef KAI_DEBUG_REGISTRY if (IsWatching(handle)) { KAI_TRACE() << handle << ": doesn't exist, not deleted"; } #endif return; } StorageBase &base = *iter->second; assert(base.GetHandle() == handle); if (!base.IsManaged() && !force) { #ifdef KAI_DEBUG_REGISTRY if (IsWatching(handle)) KAI_TRACE() << handle << ": " << base << " is not managed, not deleted"; #endif return; } #ifdef KAI_DEBUG_REGISTRY bool trace = gc_trace_level > 3; trace = trace || IsWatching(base); if (trace) { KAI_TRY { KAI_TRACE() << handle; } KAI_CATCH_ALL() { } } #endif #ifdef KAI_USE_TRICOLOR // when using tri-color GC, objects are always deleted when they are destroyed if (!base.GetClass()->Destroy(base) && !force) { base.SetColor(ObjectColor::Grey); return; } #endif base.GetClass()->Delete(base); instances.erase(iter); RetainedObjects::iterator retained = retained_objects.find(handle); if (retained != retained_objects.end()) { retained_objects.erase(retained); } succeeded = true; } KAI_CATCH(Exception::Base, E) { KAI_UNUSED(E); KAI_TRACE() << "\n\t" << E.ToString(); }