Remove Bundle dependency from Parcel 66/254966/3
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 11 Mar 2021 05:06:47 +0000 (14:06 +0900)
committerHwanKyu Jhun <h.jhun@samsung.com>
Thu, 11 Mar 2021 08:04:29 +0000 (08:04 +0000)
Requires:
 - https://review.tizen.org/gerrit/#/c/platform/core/appfw/rpc-port/+/254967/

Change-Id: I8ecfc3b8eb1753485ca85d72f473e682dd862c61
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
parcel/api/parcel.h
parcel/parcel.cc
parcel/parcel.hh
parcel/parcel.pc.in
parcel/stub.cc
tests/parcel_unittests/test_parcel.cc
tests/parcel_unittests/test_parcel_cpp.cc

index 886aa1a..6338030 100644 (file)
@@ -19,7 +19,6 @@
 
 #include <stdint.h>
 #include <stddef.h>
-#include <bundle.h>
 #include <tizen.h>
 
 /**
@@ -272,19 +271,6 @@ int parcel_write_double(parcel_h parcel, double val);
 int parcel_write_string(parcel_h parcel, const char *str);
 
 /**
- * @brief Writes a bundle data into the parcel handle.
- * @since_tizen 6.5
- * @param[in] parcel The parcel handle
- * @param[in] b The bundle data
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #PARCEL_ERROR_NONE Successful
- * @retval #PARCEL_ERROR_INVALID_PARAMETER Invalid parameter
- * @see parcel_read_bundle()
- */
-int parcel_write_bundle(parcel_h parcel, bundle* b);
-
-/**
  * @brief Reads a boolean value from the parcel handle.
  * @since_tizen 6.5
  * @param[in] parcel The parcel handle
@@ -451,22 +437,6 @@ int parcel_read_double(parcel_h parcel, double *val);
 int parcel_read_string(parcel_h parcel, char **str);
 
 /**
- * @brief Reads a bundle data from the parcel handle.
- * @since_tizen 6.5
- * @param[in] parcel The parcel handle
- * @param[out] val The bundle data
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #PARCEL_ERROR_NONE Successful
- * @retval #PARCEL_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #PARCEL_ERROR_NO_DATA No data available
- * @retval #PARCEL_ERROR_ILLEGAL_BYTE_SEQ Illegal byte sequence
- * @retval #PARCEL_ERROR_OUT_OF_MEMORY Out of memory
- * @see parcel_write_uint8()
- */
-int parcel_read_bundle(parcel_h parcel, bundle **b);
-
-/**
  * @brief Resets the reader pointer of the parcel handle to the start.
  * @since_tizen 6.5
  * @param[in] parcel The parcel handle
index 9171895..c2cb30b 100644 (file)
@@ -206,24 +206,6 @@ void Parcel::WriteCString(const char* str) {
   impl_->Write(str, strlen(str) + 1);
 }
 
-void Parcel::WriteCBundle(bundle* b) {
-  bundle_raw* raw = nullptr;
-  int len = 0;
-  bundle_encode(b, &raw, &len);
-  auto ptr = std::unique_ptr<bundle_raw, decltype(std::free)*>(raw, std::free);
-
-  auto* p = reinterpret_cast<void*>(raw);
-  impl_->WriteSize(len + 1);
-  impl_->Write(p, len + 1);
-}
-
-void Parcel::WriteBundle(const Bundle& b) {
-  auto raw = const_cast<Bundle&>(b).ToRaw();
-  auto* p = reinterpret_cast<void*>(raw.first.get());
-  impl_->WriteSize(raw.second + 1);
-  impl_->Write(p, raw.second + 1);
-}
-
 int Parcel::ReadBool(bool* val) {
   return impl_->Read<bool>(val);
 }
@@ -309,57 +291,6 @@ int Parcel::ReadCString(char** str) {
   return TIZEN_ERROR_NONE;
 }
 
-int Parcel::ReadCBundle(bundle** b) {
-  uint32_t len = 0;
-  int ret = impl_->ReadSize(&len);
-  if (ret != TIZEN_ERROR_NONE)
-    return ret;
-
-  uint8_t* raw = new (std::nothrow) uint8_t [len];
-  if (raw == nullptr)
-    return TIZEN_ERROR_OUT_OF_MEMORY;
-
-  auto ptr = std::unique_ptr<uint8_t[]>(raw);
-  ret = impl_->Read(raw, len);
-  if (ret != TIZEN_ERROR_NONE)
-    return ret;
-
-  *b = bundle_decode(reinterpret_cast<bundle_raw*>(raw), len);
-  if (*b == nullptr)
-    return get_last_result();
-
-  return TIZEN_ERROR_NONE;
-}
-
-Bundle Parcel::ReadBundle() {
-  uint32_t len = 0;
-  int ret = impl_->ReadSize(&len);
-  if (ret != TIZEN_ERROR_NONE) {
-    set_last_result(ret);
-    return {};
-  }
-
-  uint8_t* raw = new (std::nothrow) uint8_t [len];
-  if (raw == nullptr) {
-    set_last_result(TIZEN_ERROR_OUT_OF_MEMORY);
-    return {};
-  }
-
-  auto ptr = std::unique_ptr<uint8_t[]>(raw);
-  ret = impl_->Read(raw, len);
-  if (ret != TIZEN_ERROR_NONE) {
-    set_last_result(ret);
-    return {};
-  }
-
-  bundle* b = bundle_decode(reinterpret_cast<bundle_raw*>(raw), len);
-  if (b == nullptr)
-    return {};
-
-  set_last_result(TIZEN_ERROR_NONE);
-  return Bundle(b, false, true);
-}
-
 const std::vector<uint8_t>& Parcel::GetRaw() {
   return impl_->GetRaw();
 }
index 1b5f731..d924c93 100644 (file)
@@ -22,7 +22,6 @@
  * @{
  */
 
-#include <bundle_cpp.h>
 #include <tizen.h>
 
 #include <memory>
@@ -210,20 +209,6 @@ class EXPORT Parcel final {
   void WriteCString(const char* str);
 
   /**
-   * @brief Writes a bundle data into the parcel.
-   * @since_tizen 6.5
-   * @param[in] b The bundle data
-   */
-  void WriteCBundle(bundle* b);
-
-  /**
-   * @brief Writes a bundle data into the parcel.
-   * @since_tizen 6.5
-   * @param[in] b The bundle data
-   */
-  void WriteBundle(const Bundle& b);
-
-  /**
    * @brief Reads a boolean value from the parcel.
    * @since_tizen 6.5
    * @param[out] val The boolean value
@@ -342,25 +327,6 @@ class EXPORT Parcel final {
   int ReadCString(char** str);
 
   /**
-   * @brief Reads a bundle data from the parcel.
-   * @since_tizen 6.5
-   * @remarks You should release @a b using bundle_free().
-   * @param[out] b The bundle data
-   * @return @c 0 on success,
-   *         otherwise a negative error value
-   */
-  int ReadCBundle(bundle** b);
-
-  /**
-   * @brief Reads a bundle data from the parcel.
-   * @since_tizen 6.5
-   * @return The bundle data
-   * @remarks Before using the returned value, you should check the result using get_last_result().
-   * @see get_last_result();
-   */
-  Bundle ReadBundle();
-
-  /**
    * @brief Gets the raw data of the parcel.
    * @since_tizen 6.5
    * @return The raw data
index d7908b0..0238b17 100644 (file)
@@ -8,7 +8,7 @@ includedir=${prefix}/include
 Name: parcel
 Description: Parcel library
 Version: @VERSION@
-Requires: capi-base-common bundle
-Libs: -L${libdir} -lparcel -lbundle
+Requires: capi-base-common
+Libs: -L${libdir} -lparcel
 Cflags: -I${includedir} -I${includedir}/parcel
 cppflags: -I${includedir} -I${includedir}/parcel
index 24ec529..da80f8c 100644 (file)
@@ -211,17 +211,6 @@ extern "C" EXPORT int parcel_write_string(parcel_h parcel, const char* str) {
   return PARCEL_ERROR_NONE;
 }
 
-extern "C" EXPORT int parcel_write_bundle(parcel_h parcel, bundle* b) {
-  if (parcel == nullptr || b == nullptr) {
-    _E("Invalid parameter");
-    return PARCEL_ERROR_INVALID_PARAMETER;
-  }
-
-  auto* h = static_cast<Parcel*>(parcel);
-  h->WriteCBundle(b);
-  return PARCEL_ERROR_NONE;
-}
-
 extern "C" EXPORT int parcel_read_bool(parcel_h parcel, bool* val) {
   if (parcel == nullptr || val == nullptr) {
     _E("Invalid parameter");
@@ -332,16 +321,6 @@ extern "C" EXPORT int parcel_read_string(parcel_h parcel, char** str) {
   return h->ReadCString(str);
 }
 
-extern "C" EXPORT int parcel_read_bundle(parcel_h parcel, bundle** b) {
-  if (parcel == nullptr || b == nullptr) {
-    _E("Invalid parameter");
-    return PARCEL_ERROR_INVALID_PARAMETER;
-  }
-
-  auto* h = static_cast<Parcel*>(parcel);
-  return h->ReadCBundle(b);
-}
-
 extern "C" EXPORT int parcel_reset_reader(parcel_h parcel) {
   if (parcel == nullptr) {
     _E("Invalid parameter");
index 3fef107..a8aaa97 100644 (file)
@@ -271,28 +271,6 @@ TEST_F(ParcelTest, parcel_write_string_N) {
   ASSERT_EQ(ret, PARCEL_ERROR_INVALID_PARAMETER);
 }
 
-TEST_F(ParcelTest, parcel_write_bundle_P) {
-  bundle* b = bundle_create();
-  bundle_add_str(b, "Key", "Value");
-  int ret = parcel_write_bundle(GetHandle(), b);
-  bundle_free(b);
-  ASSERT_EQ(ret, PARCEL_ERROR_NONE);
-  b = nullptr;
-  ret = parcel_read_bundle(GetHandle(), &b);
-  ASSERT_NE(b, nullptr);
-  auto ptr = std::unique_ptr<std::remove_pointer<bundle>::type,
-       decltype(bundle_free)*>(b, bundle_free);
-  ASSERT_EQ(ret, PARCEL_ERROR_NONE);
-  char* str = nullptr;
-  bundle_get_str(b, "Key", &str);
-  ASSERT_EQ(std::string(str), "Value");
-}
-
-TEST_F(ParcelTest, parcel_write_bundle_N) {
-  int ret = parcel_write_bundle(nullptr, nullptr);
-  ASSERT_EQ(ret, PARCEL_ERROR_INVALID_PARAMETER);
-}
-
 TEST_F(ParcelTest, parcel_read_bool_P) {
   int ret = parcel_write_bool(GetHandle(), false);
   ASSERT_EQ(ret, PARCEL_ERROR_NONE);
@@ -449,28 +427,6 @@ TEST_F(ParcelTest, parcel_read_string_N) {
   ASSERT_EQ(ret, PARCEL_ERROR_INVALID_PARAMETER);
 }
 
-TEST_F(ParcelTest, parcel_read_bundle_P) {
-  bundle* b = bundle_create();
-  bundle_add_str(b, "Key", "Value");
-  int ret = parcel_write_bundle(GetHandle(), b);
-  bundle_free(b);
-  ASSERT_EQ(ret, PARCEL_ERROR_NONE);
-  b = nullptr;
-  ret = parcel_read_bundle(GetHandle(), &b);
-  ASSERT_NE(b, nullptr);
-  auto ptr = std::unique_ptr<std::remove_pointer<bundle>::type,
-       decltype(bundle_free)*>(b, bundle_free);
-  ASSERT_EQ(ret, PARCEL_ERROR_NONE);
-  char* str = nullptr;
-  bundle_get_str(b, "Key", &str);
-  ASSERT_EQ(std::string(str), "Value");
-}
-
-TEST_F(ParcelTest, parcel_read_bundle_N) {
-  int ret = parcel_read_bundle(nullptr, nullptr);
-  ASSERT_EQ(ret, PARCEL_ERROR_INVALID_PARAMETER);
-}
-
 TEST_F(ParcelTest, parcel_reset_reader_P) {
   int ret = parcel_reset_reader(GetHandle());
   ASSERT_EQ(ret, PARCEL_ERROR_NONE);
index 2c2f910..d3e5af0 100644 (file)
@@ -183,31 +183,6 @@ TEST_F(ParcelCppTest, WriteCString_AND_ReadCString) {
   ASSERT_EQ(std::string(str), "TestCString");
 }
 
-TEST_F(ParcelCppTest, WriteCBundle_AND_ReadCBundle) {
-  bundle* b = bundle_create();
-  bundle_add_str(b, "Key", "Value");
-  GetHandle().WriteCBundle(b);
-  bundle_free(b);
-  bundle* val = nullptr;
-  int ret = GetHandle().ReadCBundle(&val);
-  auto ptr = std::unique_ptr<bundle, decltype(bundle_free)*>(val, bundle_free);
-  ASSERT_EQ(ret, Parcel::Error::None);
-  ASSERT_NE(val, nullptr);
-  char* str = nullptr;
-  bundle_get_str(val, "Key", &str);
-  ASSERT_EQ(std::string(str), "Value");
-}
-
-TEST_F(ParcelCppTest, WriteBundle_AND_ReadBundle) {
-  Bundle b;
-  b.Add("Key", "Value");
-  GetHandle().WriteBundle(b);
-  auto val = GetHandle().ReadBundle();
-  ASSERT_EQ(get_last_result(), Parcel::Error::None);
-  auto str = val.GetString("Key");
-  ASSERT_EQ(str, "Value");
-}
-
 TEST_F(ParcelCppTest, GetRaw) {
   GetHandle().WriteInt32(0);
   auto& raw = GetHandle().GetRaw();