Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: refine behavior when get property with incorrect type #353

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
"request": "launch",
"program": "${workspaceFolder}/out/linux/x64/tests/standalone/ten_runtime_smoke_test",
"args": [
"--gtest_filter=PropertyTest.GetFloat64TypeButIntValue"
"--gtest_filter=PropertyTest.GetInt32"
],
"cwd": "${workspaceFolder}/out/linux/x64/tests/standalone/",
"env": {
Expand Down
11 changes: 4 additions & 7 deletions core/include/ten_runtime/binding/cpp/detail/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,16 @@ class app_t {
return false;
}

return ten_app_run(
c_app, run_in_background,
err != nullptr ? err->get_internal_representation() : nullptr);
return ten_app_run(c_app, run_in_background,
err != nullptr ? err->get_c_error() : nullptr);
}

bool close(error_t *err = nullptr) {
return ten_app_close(
c_app, err != nullptr ? err->get_internal_representation() : nullptr);
return ten_app_close(c_app, err != nullptr ? err->get_c_error() : nullptr);
}

bool wait(error_t *err = nullptr) {
return ten_app_wait(
c_app, err != nullptr ? err->get_internal_representation() : nullptr);
return ten_app_wait(c_app, err != nullptr ? err->get_c_error() : nullptr);
}

protected:
Expand Down
16 changes: 6 additions & 10 deletions core/include/ten_runtime/binding/cpp/detail/msg/audio_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,16 @@ class audio_frame_t : public msg_t {
static std::unique_ptr<audio_frame_t> create(const char *audio_frame_name,
error_t *err = nullptr) {
if (audio_frame_name == nullptr || strlen(audio_frame_name) == 0) {
if (err != nullptr && err->get_internal_representation() != nullptr) {
ten_error_set(err->get_internal_representation(),
TEN_ERRNO_INVALID_ARGUMENT,
if (err != nullptr && err->get_c_error() != nullptr) {
ten_error_set(err->get_c_error(), TEN_ERRNO_INVALID_ARGUMENT,
"audio frame name cannot be empty.");
}
return nullptr;
}

auto *c_frame = ten_audio_frame_create();
ten_msg_set_name(
c_frame, audio_frame_name,
err != nullptr ? err->get_internal_representation() : nullptr);
ten_msg_set_name(c_frame, audio_frame_name,
err != nullptr ? err->get_c_error() : nullptr);

return std::make_unique<audio_frame_t>(c_frame, ctor_passkey_t());
}
Expand Down Expand Up @@ -130,8 +128,7 @@ class audio_frame_t : public msg_t {
ten_buf_t *data = ten_audio_frame_peek_buf(c_msg);

if (!ten_msg_add_locked_res_buf(
c_msg, data->data,
err != nullptr ? err->get_internal_representation() : nullptr)) {
c_msg, data->data, err != nullptr ? err->get_c_error() : nullptr)) {
return buf_t{};
}

Expand All @@ -143,8 +140,7 @@ class audio_frame_t : public msg_t {
bool unlock_buf(buf_t &buf, error_t *err = nullptr) {
const uint8_t *data = buf.data();
if (!ten_msg_remove_locked_res_buf(
c_msg, data,
err != nullptr ? err->get_internal_representation() : nullptr)) {
c_msg, data, err != nullptr ? err->get_c_error() : nullptr)) {
return false;
}

Expand Down
5 changes: 2 additions & 3 deletions core/include/ten_runtime/binding/cpp/detail/msg/cmd/cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ class cmd_t : public msg_t {
public:
static std::unique_ptr<cmd_t> create(const char *cmd_name,
error_t *err = nullptr) {
ten_shared_ptr_t *c_cmd = ten_cmd_create(
cmd_name,
err != nullptr ? err->get_internal_representation() : nullptr);
ten_shared_ptr_t *c_cmd =
ten_cmd_create(cmd_name, err != nullptr ? err->get_c_error() : nullptr);

return std::make_unique<cmd_t>(c_cmd, ctor_passkey_t());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,18 @@ class cmd_start_graph_t : public cmd_t {
error_t *err = nullptr) {
return ten_cmd_start_graph_set_predefined_graph_name(
c_msg, predefined_graph_name,
err != nullptr ? err->get_internal_representation() : nullptr);
err != nullptr ? err->get_c_error() : nullptr);
}

bool set_graph_from_json(const char *json_str, error_t *err = nullptr) {
return ten_cmd_start_graph_set_graph_from_json_str(
c_msg, json_str,
err != nullptr ? err->get_internal_representation() : nullptr);
c_msg, json_str, err != nullptr ? err->get_c_error() : nullptr);
}

bool set_long_running_mode(bool long_running_mode, error_t *err = nullptr) {
return ten_cmd_start_graph_set_long_running_mode(
c_msg, long_running_mode,
err != nullptr ? err->get_internal_representation() : nullptr);
err != nullptr ? err->get_c_error() : nullptr);
}

// @{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,17 @@ class cmd_result_t : public msg_t {

bool is_final(error_t *err = nullptr) const {
return ten_cmd_result_is_final(
c_msg, err != nullptr ? err->get_internal_representation() : nullptr);
c_msg, err != nullptr ? err->get_c_error() : nullptr);
}

bool is_completed(error_t *err = nullptr) const {
return ten_cmd_result_is_completed(
c_msg, err != nullptr ? err->get_internal_representation() : nullptr);
c_msg, err != nullptr ? err->get_c_error() : nullptr);
}

bool set_final(bool final, error_t *err = nullptr) {
return ten_cmd_result_set_final(
c_msg, final,
err != nullptr ? err->get_internal_representation() : nullptr);
c_msg, final, err != nullptr ? err->get_c_error() : nullptr);
}

// @{
Expand Down
16 changes: 7 additions & 9 deletions core/include/ten_runtime/binding/cpp/detail/msg/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,16 @@ class data_t : public msg_t {
static std::unique_ptr<data_t> create(const char *data_name,
error_t *err = nullptr) {
if (data_name == nullptr || strlen(data_name) == 0) {
if (err != nullptr && err->get_internal_representation() != nullptr) {
ten_error_set(err->get_internal_representation(),
TEN_ERRNO_INVALID_ARGUMENT, "Data name cannot be empty.");
if (err != nullptr && err->get_c_error() != nullptr) {
ten_error_set(err->get_c_error(), TEN_ERRNO_INVALID_ARGUMENT,
"Data name cannot be empty.");
}
return nullptr;
}

auto *c_data = ten_data_create();
ten_msg_set_name(
c_data, data_name,
err != nullptr ? err->get_internal_representation() : nullptr);
ten_msg_set_name(c_data, data_name,
err != nullptr ? err->get_c_error() : nullptr);

return std::make_unique<data_t>(c_data, ctor_passkey_t());
}
Expand All @@ -65,7 +64,7 @@ class data_t : public msg_t {
buf_t lock_buf(error_t *err = nullptr) {
if (!ten_msg_add_locked_res_buf(
c_msg, ten_data_peek_buf(c_msg)->data,
err != nullptr ? err->get_internal_representation() : nullptr)) {
err != nullptr ? err->get_c_error() : nullptr)) {
return {};
}

Expand All @@ -77,8 +76,7 @@ class data_t : public msg_t {

bool unlock_buf(buf_t &buf, error_t *err = nullptr) {
if (!ten_msg_remove_locked_res_buf(
c_msg, buf.data(),
err != nullptr ? err->get_internal_representation() : nullptr)) {
c_msg, buf.data(), err != nullptr ? err->get_c_error() : nullptr)) {
return false;
}

Expand Down
Loading