예제 #1
0
 void JSObject::RegisterPrivateData(JSObjectRef js_object_ref, void* private_data) {
   HAL_JSOBJECT_LOCK_GUARD_STATIC;
   // we won't store nullptr
   if (private_data == nullptr) {
     return;
   }
   const auto key   = reinterpret_cast<std::intptr_t>(private_data);
   const auto value = reinterpret_cast<std::intptr_t>(js_object_ref);
   
   const auto position = js_private_data_to_js_object_ref_map__.find(key);
   const bool found    = position != js_private_data_to_js_object_ref_map__.end();
   
   if (found) {
     // private data should not be shared by multiple JSObjectRef
     assert((reinterpret_cast<JSObjectRef>(position -> second) == js_object_ref));
   } else {
     const auto insert_result = js_private_data_to_js_object_ref_map__.emplace(key, value);
     const bool inserted      = insert_result.second;
     
     // postcondition
     assert(inserted);
     
     HAL_LOG_DEBUG("JSObject::RegisterPrivateData: JSObjectRef = ", js_object_ref, ", data = ", private_data);
   }
 }
예제 #2
0
 void JSObject::UnRegisterPrivateData(void* private_data) {
   HAL_JSOBJECT_LOCK_GUARD_STATIC;
   // we won't store nullptr
   if (private_data == nullptr) {
     return;
   }
   const auto key      = reinterpret_cast<std::intptr_t>(private_data);
   const auto position = js_private_data_to_js_object_ref_map__.find(key);
   const bool found    = position != js_private_data_to_js_object_ref_map__.end();
   
   if (found) {
     JSObjectRef js_object_ref = reinterpret_cast<JSObjectRef>(position -> second);
     static_cast<void>(js_object_ref); // just meant to suppress "unused" compiler warning
     js_private_data_to_js_object_ref_map__.erase(key);
     HAL_LOG_DEBUG("JSObject::UnRegisterPrivateData: data = ", private_data, ", JSObjectRef = ", js_object_ref);
   } else {
     HAL_LOG_DEBUG("JSObject::UnRegisterPrivateData: data = ", private_data, " not registered");
   }
 }
예제 #3
0
 void JSObject::UnRegisterJSContext(JSObjectRef js_object_ref) {
   HAL_JSOBJECT_LOCK_GUARD_STATIC;
   const auto key      = reinterpret_cast<std::intptr_t>(js_object_ref);
   const auto position = js_object_ref_to_js_context_ref_map__.find(key);
   const bool found    = position != js_object_ref_to_js_context_ref_map__.end();
   
   // precondition
   if (found) {
     auto tuple = position -> second;
     JSContextRef js_context_ref = reinterpret_cast<JSContextRef>(std::get<0>(tuple));
     static_cast<void>(js_context_ref); // just meant to suppress "unused" compiler warning
     --std::get<1>(tuple);
     if (std::get<1>(tuple) == 0) {
       js_object_ref_to_js_context_ref_map__.erase(key);
     } else {
       js_object_ref_to_js_context_ref_map__[key] = tuple;
     }
     HAL_LOG_DEBUG("JSObject::UnRegisterJSContext: JSObjectRef = ", js_object_ref, ", JSContextRef = ", js_context_ref, " count = ", std::get<1>(tuple));
   } else {
     HAL_LOG_DEBUG("JSObject::UnRegisterJSContext: JSObjectRef = ", js_object_ref, " not registered");
   }
 }
예제 #4
0
 void JSObject::RegisterJSContext(JSContextRef js_context_ref, JSObjectRef js_object_ref) {
   HAL_JSOBJECT_LOCK_GUARD_STATIC;
   const auto key   = reinterpret_cast<std::intptr_t>(js_object_ref);
   const auto value = reinterpret_cast<std::intptr_t>(js_context_ref);
   
   const auto position = js_object_ref_to_js_context_ref_map__.find(key);
   const bool found    = position != js_object_ref_to_js_context_ref_map__.end();
   
   if (found) {
     auto tuple = position -> second;
     ++std::get<1>(tuple);
     js_object_ref_to_js_context_ref_map__[key] = tuple;
     
     HAL_LOG_DEBUG("JSObject::RegisterJSContext: JSObjectRef = ", js_object_ref, ", JSContextRef = ", js_context_ref, " count = ", std::get<1>(tuple));
   } else {
     const auto insert_result = js_object_ref_to_js_context_ref_map__.emplace(key, std::make_tuple(value, 1));
     const bool inserted      = insert_result.second;
     
     // postcondition
     assert(inserted);
     HAL_LOG_DEBUG("JSObject::RegisterJSContext: JSObjectRef = ", js_object_ref, ", JSContextRef = ", js_context_ref, " count = 1");
   }
 }
		void ListSection::postCallAsConstructor(const JSContext& js_context, const std::vector<JSValue>& arguments) {
			HAL_LOG_DEBUG("ListSection:: postCallAsConstructor ", this);
		}
예제 #6
0
void OtherWidget::postCallAsConstructor(const JSContext& js_context, const std::vector<JSValue>& arguments) {
  HAL_LOG_DEBUG("OtherWidget:: postCallAsConstructor ", this);
}
예제 #7
0
void OtherWidget::postInitialize(JSObject& js_object) {
  HAL_LOG_DEBUG("OtherWidget:: postInitialize ", this);
}