From ced7742b5cac320f250bca0ae15941e401eaffbb Mon Sep 17 00:00:00 2001 From: adonia Date: Thu, 19 Sep 2024 19:31:44 +0800 Subject: [PATCH 1/4] fix: coredump when cmd has not connected --- .../binding/go/native/ten_env/ten_env_is_cmd_connected.c | 3 +-- .../binding/go/native/ten_env/ten_env_set_property.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/core/src/ten_runtime/binding/go/native/ten_env/ten_env_is_cmd_connected.c b/core/src/ten_runtime/binding/go/native/ten_env/ten_env_is_cmd_connected.c index f6ca07b56e..e1934c5b07 100644 --- a/core/src/ten_runtime/binding/go/native/ten_env/ten_env_is_cmd_connected.c +++ b/core/src/ten_runtime/binding/go/native/ten_env/ten_env_is_cmd_connected.c @@ -6,10 +6,10 @@ // #include "include_internal/ten_runtime/binding/go/ten_env/ten_env.h" #include "include_internal/ten_runtime/binding/go/ten_env/ten_env_internal.h" -#include "ten_utils/macro/check.h" #include "ten_runtime/binding/go/interface/ten/ten_env.h" #include "ten_runtime/ten_env_proxy/ten_env_proxy.h" #include "ten_utils/lib/alloc.h" +#include "ten_utils/macro/check.h" typedef struct ten_env_notify_is_cmd_connected_info_t { bool result; @@ -53,7 +53,6 @@ static void ten_notify_is_cmd_connected(ten_env_t *ten_env, void *user_data) { info->result = ten_env_is_cmd_connected( ten_env, ten_string_get_raw_str(&info->name), &err); - TEN_ASSERT(info->result, "Should not happen."); ten_event_set(info->completed); diff --git a/core/src/ten_runtime/binding/go/native/ten_env/ten_env_set_property.c b/core/src/ten_runtime/binding/go/native/ten_env/ten_env_set_property.c index 23c2019c0f..db111a20f9 100644 --- a/core/src/ten_runtime/binding/go/native/ten_env/ten_env_set_property.c +++ b/core/src/ten_runtime/binding/go/native/ten_env/ten_env_set_property.c @@ -11,7 +11,6 @@ #include "include_internal/ten_runtime/binding/go/ten_env/ten_env.h" #include "include_internal/ten_runtime/binding/go/ten_env/ten_env_internal.h" #include "include_internal/ten_runtime/binding/go/value/value.h" -#include "ten_utils/macro/check.h" #include "ten_runtime/binding/go/interface/ten/common.h" #include "ten_runtime/binding/go/interface/ten/ten_env.h" #include "ten_runtime/binding/go/interface/ten/value.h" @@ -22,6 +21,7 @@ #include "ten_utils/lib/event.h" #include "ten_utils/lib/json.h" #include "ten_utils/lib/string.h" +#include "ten_utils/macro/check.h" #include "ten_utils/value/value.h" typedef struct ten_env_notify_set_property_info_t { @@ -70,7 +70,6 @@ static void ten_env_notify_set_property(ten_env_t *ten_env, void *user_data) { info->result = ten_env_set_property( ten_env, ten_string_get_raw_str(&info->path), info->c_value, &err); - TEN_ASSERT(info->result, "Should not happen."); ten_event_set(info->completed); From 3eb64cd579966694b25f515e8a365804bad613f6 Mon Sep 17 00:00:00 2001 From: adonia Date: Fri, 20 Sep 2024 11:17:48 +0800 Subject: [PATCH 2/4] fix: return value --- .../binding/go/native/ten_env/ten_env_is_cmd_connected.c | 1 + .../extension/default_extension_go/default_extension.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/core/src/ten_runtime/binding/go/native/ten_env/ten_env_is_cmd_connected.c b/core/src/ten_runtime/binding/go/native/ten_env/ten_env_is_cmd_connected.c index e1934c5b07..cc9e57850c 100644 --- a/core/src/ten_runtime/binding/go/native/ten_env/ten_env_is_cmd_connected.c +++ b/core/src/ten_runtime/binding/go/native/ten_env/ten_env_is_cmd_connected.c @@ -81,6 +81,7 @@ bool ten_go_ten_env_is_cmd_connected(uintptr_t bridge_addr, const char *name) { } ten_event_wait(info->completed, -1); + result = info->result; done: ten_error_deinit(&err); diff --git a/tests/ten_runtime/integration/go/frequently_cgo_call_go/frequently_cgo_call_go_app/ten_packages/extension/default_extension_go/default_extension.go b/tests/ten_runtime/integration/go/frequently_cgo_call_go/frequently_cgo_call_go_app/ten_packages/extension/default_extension_go/default_extension.go index ba53b09e8a..dd363be109 100644 --- a/tests/ten_runtime/integration/go/frequently_cgo_call_go/frequently_cgo_call_go_app/ten_packages/extension/default_extension_go/default_extension.go +++ b/tests/ten_runtime/integration/go/frequently_cgo_call_go/frequently_cgo_call_go_app/ten_packages/extension/default_extension_go/default_extension.go @@ -133,6 +133,11 @@ func (p *extensionB) OnCmd( go func() { fmt.Println("extensionB OnCmd") + connected, err := tenEnv.IsCmdConnected("cmd_not_exist") + if err != nil || connected { + panic("Should not happen.") + } + cmdName, _ := cmd.GetName() if cmdName == "B" { var count uint32 = 0 From 4868861ca69d8d1efa64d186b06fd57176e07778 Mon Sep 17 00:00:00 2001 From: adonia Date: Fri, 20 Sep 2024 16:50:31 +0800 Subject: [PATCH 3/4] feat: add configure api --- .../binding/go/interface/ten/extension.go | 44 ++++++++++++- .../binding/go/interface/ten/ten_env.go | 1 + .../binding/go/interface/ten/ten_env.h | 3 + .../binding/go/interface/ten/ten_property.go | 13 ++++ .../binding/go/native/extension/extension.c | 29 +++++++-- .../go/native/ten_env/ten_env_init_property.c | 62 +++++++++++++++++-- .../go/native/ten_env/ten_env_set_property.c | 19 ++---- .../default_extension_go/default_extension.go | 25 ++++++++ 8 files changed, 171 insertions(+), 25 deletions(-) diff --git a/core/src/ten_runtime/binding/go/interface/ten/extension.go b/core/src/ten_runtime/binding/go/interface/ten/extension.go index 0342d06c07..a49c801c74 100644 --- a/core/src/ten_runtime/binding/go/interface/ten/extension.go +++ b/core/src/ten_runtime/binding/go/interface/ten/extension.go @@ -18,6 +18,7 @@ import ( ) type Extension interface { + OnConfigure(tenEnv TenEnv) OnInit( tenEnv TenEnv, ) @@ -35,6 +36,10 @@ type DefaultExtension struct{} var _ Extension = new(DefaultExtension) +func (p *DefaultExtension) OnConfigure(tenEnv TenEnv) { + tenEnv.OnConfigureDone() +} + func (p *DefaultExtension) OnInit( tenEnv TenEnv, ) { @@ -132,8 +137,8 @@ func newExtensionWithBridge( } // -//export tenGoExtensionOnInit -func tenGoExtensionOnInit( +//export tenGoExtensionOnConfigure +func tenGoExtensionOnConfigure( extensionID C.uintptr_t, tenEnvID C.uintptr_t, ) { @@ -165,6 +170,41 @@ func tenGoExtensionOnInit( tenEnvInstance.attachToExtension(extensionObj) + extensionObj.OnConfigure(tenEnvObj) +} + +// +//export tenGoExtensionOnInit +func tenGoExtensionOnInit( + extensionID C.uintptr_t, + tenEnvID C.uintptr_t, +) { + extensionObj, ok := loadImmutableHandle(goHandle(extensionID)).(*extension) + if !ok { + panic( + fmt.Sprintf( + "Failed to get extension from handle map, id: %d.", + uintptr(extensionID), + ), + ) + } + + tenEnvObj, ok := handle(tenEnvID).get().(TenEnv) + if !ok { + panic( + fmt.Sprintf( + "Failed to get ten from handle map, id: %d.", + uintptr(tenEnvID), + ), + ) + } + + tenEnvInstance, ok := tenEnvObj.(*tenEnv) + if tenEnvInstance == nil || !ok { + // Should not happen. + panic("Invalid ten object type.") + } + // As the `extension` struct embeds a user-defined extension instance // implements the Extension interface, the `OnInit` method can be called // directly on the `extensionObj` object. The receiver of the `OnInit` diff --git a/core/src/ten_runtime/binding/go/interface/ten/ten_env.go b/core/src/ten_runtime/binding/go/interface/ten/ten_env.go index 01c173cf79..2f9e096c77 100644 --- a/core/src/ten_runtime/binding/go/interface/ten/ten_env.go +++ b/core/src/ten_runtime/binding/go/interface/ten/ten_env.go @@ -77,6 +77,7 @@ type TenEnv interface { ) error InitPropertyFromJSONBytes(value []byte) error + InitManifestFromJSONBytes(value []byte) error LogVerbose(msg string) LogDebug(msg string) diff --git a/core/src/ten_runtime/binding/go/interface/ten/ten_env.h b/core/src/ten_runtime/binding/go/interface/ten/ten_env.h index 52e99d7842..def9f28c43 100644 --- a/core/src/ten_runtime/binding/go/interface/ten/ten_env.h +++ b/core/src/ten_runtime/binding/go/interface/ten/ten_env.h @@ -355,6 +355,9 @@ ten_go_status_t ten_go_ten_env_set_property_json_bytes(uintptr_t bridge_addr, ten_go_status_t ten_go_ten_env_init_property_from_json_bytes( uintptr_t bridge_addr, const void *json_str, int json_str_len); +ten_go_status_t ten_go_ten_env_init_manifest_from_json_bytes( + uintptr_t bridge_addr, const void *json_str, int json_str_len); + void ten_go_ten_env_log(uintptr_t bridge_addr, int level, const void *func_name, int func_name_len, const void *file_name, int file_name_len, int line_no, const void *msg, diff --git a/core/src/ten_runtime/binding/go/interface/ten/ten_property.go b/core/src/ten_runtime/binding/go/interface/ten/ten_property.go index d71f52a017..8681270922 100644 --- a/core/src/ten_runtime/binding/go/interface/ten/ten_property.go +++ b/core/src/ten_runtime/binding/go/interface/ten/ten_property.go @@ -690,3 +690,16 @@ func (p *tenEnv) InitPropertyFromJSONBytes(value []byte) error { return err } + +func (p *tenEnv) InitManifestFromJSONBytes(value []byte) error { + defer p.keepAlive() + + apiStatus := C.ten_go_ten_env_init_manifest_from_json_bytes( + p.cPtr, + unsafe.Pointer(unsafe.SliceData(value)), + C.int(len(value)), + ) + err := withGoStatus(&apiStatus) + + return err +} diff --git a/core/src/ten_runtime/binding/go/native/extension/extension.c b/core/src/ten_runtime/binding/go/native/extension/extension.c index 70c8727719..88714b19ae 100644 --- a/core/src/ten_runtime/binding/go/native/extension/extension.c +++ b/core/src/ten_runtime/binding/go/native/extension/extension.c @@ -27,6 +27,9 @@ #include "ten_utils/lib/string.h" #include "ten_utils/macro/check.h" +extern void tenGoExtensionOnConfigure(ten_go_handle_t go_extension, + ten_go_handle_t go_ten); + extern void tenGoExtensionOnInit(ten_go_handle_t go_extension, ten_go_handle_t go_ten); @@ -96,7 +99,7 @@ static void ten_go_extension_bridge_destroy(ten_go_extension_t *self) { TEN_FREE(self); } -static void proxy_on_init(ten_extension_t *self, ten_env_t *ten_env) { +static void proxy_on_configure(ten_extension_t *self, ten_env_t *ten_env) { TEN_ASSERT(self && ten_extension_check_integrity(self, true), "Should not happen."); TEN_ASSERT(ten_env && ten_env_check_integrity(ten_env, true), @@ -111,6 +114,24 @@ static void proxy_on_init(ten_extension_t *self, ten_env_t *ten_env) { ten_go_ten_env_t *ten_bridge = ten_go_ten_env_wrap(ten_env); ten_bridge->c_ten_env_proxy = ten_env_proxy_create(ten_env, 1, NULL); + tenGoExtensionOnConfigure(ten_go_extension_go_handle(extension_bridge), + ten_go_ten_env_go_handle(ten_bridge)); +} + +static void proxy_on_init(ten_extension_t *self, ten_env_t *ten_env) { + TEN_ASSERT(self && ten_extension_check_integrity(self, true), + "Should not happen."); + TEN_ASSERT(ten_env && ten_env_check_integrity(ten_env, true), + "Should not happen."); + TEN_ASSERT(ten_extension_get_ten(self) == ten_env, "Should not happen."); + + ten_go_extension_t *extension_bridge = + ten_binding_handle_get_me_in_target_lang((ten_binding_handle_t *)self); + TEN_ASSERT(ten_go_extension_check_integrity(extension_bridge), + "Should not happen."); + + ten_go_ten_env_t *ten_bridge = ten_go_ten_env_wrap(ten_env); + tenGoExtensionOnInit(ten_go_extension_go_handle(extension_bridge), ten_go_ten_env_go_handle(ten_bridge)); } @@ -285,9 +306,9 @@ ten_go_extension_t *ten_go_extension_create_internal( extension_bridge->bridge.sp_ref_by_c = NULL; extension_bridge->c_extension = ten_extension_create( - name, NULL, proxy_on_init, proxy_on_start, proxy_on_stop, proxy_on_deinit, - proxy_on_cmd, proxy_on_data, proxy_on_audio_frame, proxy_on_video_frame, - NULL); + name, proxy_on_configure, proxy_on_init, proxy_on_start, proxy_on_stop, + proxy_on_deinit, proxy_on_cmd, proxy_on_data, proxy_on_audio_frame, + proxy_on_video_frame, NULL); ten_binding_handle_set_me_in_target_lang( &extension_bridge->c_extension->binding_handle, extension_bridge); diff --git a/core/src/ten_runtime/binding/go/native/ten_env/ten_env_init_property.c b/core/src/ten_runtime/binding/go/native/ten_env/ten_env_init_property.c index 4b0c364d6e..ae63501046 100644 --- a/core/src/ten_runtime/binding/go/native/ten_env/ten_env_init_property.c +++ b/core/src/ten_runtime/binding/go/native/ten_env/ten_env_init_property.c @@ -7,7 +7,7 @@ #include "include_internal/ten_runtime/binding/go/internal/common.h" #include "include_internal/ten_runtime/binding/go/ten_env/ten_env.h" #include "include_internal/ten_runtime/binding/go/ten_env/ten_env_internal.h" -#include "ten_utils/macro/check.h" +#include "include_internal/ten_runtime/ten_env/metadata.h" #include "ten_runtime/binding/go/interface/ten/common.h" #include "ten_runtime/binding/go/interface/ten/ten_env.h" #include "ten_runtime/common/errno.h" @@ -20,6 +20,7 @@ typedef struct ten_notify_set_init_property_info_t { ten_string_t value; + ten_error_t err; ten_event_t *completed; } ten_env_notify_init_property_info_t; @@ -30,6 +31,7 @@ ten_env_notify_init_property_info_create(const void *value, int value_len) { TEN_ASSERT(info, "Failed to allocate memory."); ten_string_init_formatted(&info->value, "%.*s", value_len, value); + ten_error_init(&info->err); info->completed = ten_event_create(0, 1); return info; @@ -40,6 +42,7 @@ static void ten_env_notify_init_property_info_destroy( TEN_ASSERT(self, "Invalid argument."); ten_string_deinit(&self->value); + ten_error_deinit(&self->err); ten_event_destroy(self->completed); TEN_FREE(self); @@ -65,6 +68,21 @@ static void ten_env_notify_init_property_from_json(ten_env_t *ten_env, ten_error_deinit(&err); } +static void ten_env_notify_init_manifest_from_json(ten_env_t *ten_env, + void *user_data) { + TEN_ASSERT(user_data, "Invalid argument."); + TEN_ASSERT(ten_env && ten_env_check_integrity(ten_env, true), + "Should not happen."); + + ten_env_notify_init_property_info_t *info = user_data; + TEN_ASSERT(info, "Should not happen."); + + ten_env_init_manifest_from_json(ten_env, ten_string_get_raw_str(&info->value), + &info->err); + + ten_event_set(info->completed); +} + ten_go_status_t ten_go_ten_env_init_property_from_json_bytes( uintptr_t bridge_addr, const void *json_str, int json_str_len) { ten_go_ten_env_t *self = ten_go_ten_env_reinterpret(bridge_addr); @@ -79,24 +97,56 @@ ten_go_status_t ten_go_ten_env_init_property_from_json_bytes( return status; }); - ten_error_t err; - ten_error_init(&err); ten_env_notify_init_property_info_t *info = ten_env_notify_init_property_info_create(json_str, json_str_len); TEN_ASSERT(info, "Should not happen."); if (!ten_env_proxy_notify(self->c_ten_env_proxy, ten_env_notify_init_property_from_json, info, false, - &err)) { - ten_go_status_from_error(&status, &err); + &info->err)) { goto done; } ten_event_wait(info->completed, -1); done: + ten_go_status_from_error(&status, &info->err); + ten_env_notify_init_property_info_destroy(info); + TEN_GO_TEN_IS_ALIVE_REGION_END(self); + +ten_is_close: + return status; +} + +ten_go_status_t ten_go_ten_env_init_manifest_from_json_bytes( + uintptr_t bridge_addr, const void *json_str, int json_str_len) { + ten_go_ten_env_t *self = ten_go_ten_env_reinterpret(bridge_addr); + TEN_ASSERT(self && ten_go_ten_env_check_integrity(self), + "Should not happen."); + + ten_go_status_t status; + ten_go_status_init_with_errno(&status, TEN_ERRNO_OK); + + TEN_GO_TEN_IS_ALIVE_REGION_BEGIN(self, { + ten_go_status_init_with_errno(&status, TEN_ERRNO_TEN_IS_CLOSED); + return status; + }); + + ten_env_notify_init_property_info_t *info = + ten_env_notify_init_property_info_create(json_str, json_str_len); + TEN_ASSERT(info, "Should not happen."); + + if (!ten_env_proxy_notify(self->c_ten_env_proxy, + ten_env_notify_init_manifest_from_json, info, false, + &info->err)) { + goto done; + } + + ten_event_wait(info->completed, -1); + +done: + ten_go_status_from_error(&status, &info->err); ten_env_notify_init_property_info_destroy(info); - ten_error_deinit(&err); TEN_GO_TEN_IS_ALIVE_REGION_END(self); ten_is_close: diff --git a/core/src/ten_runtime/binding/go/native/ten_env/ten_env_set_property.c b/core/src/ten_runtime/binding/go/native/ten_env/ten_env_set_property.c index db111a20f9..a64a54dca2 100644 --- a/core/src/ten_runtime/binding/go/native/ten_env/ten_env_set_property.c +++ b/core/src/ten_runtime/binding/go/native/ten_env/ten_env_set_property.c @@ -26,6 +26,7 @@ typedef struct ten_env_notify_set_property_info_t { bool result; + ten_error_t err; ten_string_t path; ten_value_t *c_value; ten_event_t *completed; @@ -39,6 +40,7 @@ ten_env_notify_set_property_info_create(const void *path, int path_len, TEN_ASSERT(info, "Failed to allocate memory."); info->result = true; + ten_error_init(&info->err); ten_string_init_formatted(&info->path, "%.*s", path_len, path); info->c_value = value; info->completed = ten_event_create(0, 1); @@ -50,6 +52,7 @@ static void ten_env_notify_set_property_info_destroy( ten_env_notify_set_property_info_t *self) { TEN_ASSERT(self, "Invalid argument."); + ten_error_deinit(&self->err); ten_string_deinit(&self->path); self->c_value = NULL; ten_event_destroy(self->completed); @@ -65,15 +68,10 @@ static void ten_env_notify_set_property(ten_env_t *ten_env, void *user_data) { ten_env_notify_set_property_info_t *info = user_data; TEN_ASSERT(info, "Should not happen."); - ten_error_t err; - ten_error_init(&err); - info->result = ten_env_set_property( - ten_env, ten_string_get_raw_str(&info->path), info->c_value, &err); + ten_env, ten_string_get_raw_str(&info->path), info->c_value, &info->err); ten_event_set(info->completed); - - ten_error_deinit(&err); } static void ten_go_ten_env_set_property(ten_go_ten_env_t *self, @@ -89,25 +87,20 @@ static void ten_go_ten_env_set_property(ten_go_ten_env_t *self, ten_go_status_set_errno(status, TEN_ERRNO_TEN_IS_CLOSED); }); - ten_error_t err; - ten_error_init(&err); - ten_env_notify_set_property_info_t *info = ten_env_notify_set_property_info_create(path, path_len, value); if (!ten_env_proxy_notify(self->c_ten_env_proxy, ten_env_notify_set_property, - info, false, &err)) { - ten_go_status_from_error(status, &err); + info, false, &info->err)) { goto done; } ten_event_wait(info->completed, -1); done: + ten_go_status_from_error(status, &info->err); ten_env_notify_set_property_info_destroy(info); - ten_error_deinit(&err); - TEN_GO_TEN_IS_ALIVE_REGION_END(self); ten_is_close: diff --git a/tests/ten_runtime/integration/go/access_property_go/access_property_go_app/ten_packages/extension/default_extension_go/default_extension.go b/tests/ten_runtime/integration/go/access_property_go/access_property_go_app/ten_packages/extension/default_extension_go/default_extension.go index f6fb1ff069..0490883d5e 100644 --- a/tests/ten_runtime/integration/go/access_property_go/access_property_go_app/ten_packages/extension/default_extension_go/default_extension.go +++ b/tests/ten_runtime/integration/go/access_property_go/access_property_go_app/ten_packages/extension/default_extension_go/default_extension.go @@ -43,10 +43,35 @@ type aExtension struct { baseExtension } +func (p *aExtension) OnConfigure(tenEnv ten.TenEnv) { + if err := tenEnv.InitManifestFromJSONBytes([]byte(`{ + "type": "extension", + "name": "A", + "version": "0.0.1", + "api": { + "property": { + "prop_int": { + "type": "int8" + } + } + } + }`)); err != nil { + panic("Should not happen.") + } + + tenEnv.OnConfigureDone() +} + func (p *aExtension) OnCmd( tenEnv ten.TenEnv, cmd ten.Cmd, ) { + if err := tenEnv.SetProperty("prop_int", false); err == nil { + panic("Should not happen, the schema is not matched.") + } else { + println("SetProperty failed: ", err.Error()) + } + if err := tenEnv.SetProperty("testBool", false); err != nil { panic("Should not happen.") } From 08fff764193530080bc40cf4004b015a59d1716c Mon Sep 17 00:00:00 2001 From: adonia Date: Fri, 20 Sep 2024 20:35:45 +0800 Subject: [PATCH 4/4] fix: remove unexported api --- .../binding/go/interface/ten/ten_env.go | 1 - .../binding/go/interface/ten/ten_env.h | 3 -- .../binding/go/interface/ten/ten_property.go | 13 ----- .../go/native/ten_env/ten_env_init_property.c | 51 ------------------- .../default_extension_go/default_extension.go | 25 --------- 5 files changed, 93 deletions(-) diff --git a/core/src/ten_runtime/binding/go/interface/ten/ten_env.go b/core/src/ten_runtime/binding/go/interface/ten/ten_env.go index 2f9e096c77..01c173cf79 100644 --- a/core/src/ten_runtime/binding/go/interface/ten/ten_env.go +++ b/core/src/ten_runtime/binding/go/interface/ten/ten_env.go @@ -77,7 +77,6 @@ type TenEnv interface { ) error InitPropertyFromJSONBytes(value []byte) error - InitManifestFromJSONBytes(value []byte) error LogVerbose(msg string) LogDebug(msg string) diff --git a/core/src/ten_runtime/binding/go/interface/ten/ten_env.h b/core/src/ten_runtime/binding/go/interface/ten/ten_env.h index def9f28c43..52e99d7842 100644 --- a/core/src/ten_runtime/binding/go/interface/ten/ten_env.h +++ b/core/src/ten_runtime/binding/go/interface/ten/ten_env.h @@ -355,9 +355,6 @@ ten_go_status_t ten_go_ten_env_set_property_json_bytes(uintptr_t bridge_addr, ten_go_status_t ten_go_ten_env_init_property_from_json_bytes( uintptr_t bridge_addr, const void *json_str, int json_str_len); -ten_go_status_t ten_go_ten_env_init_manifest_from_json_bytes( - uintptr_t bridge_addr, const void *json_str, int json_str_len); - void ten_go_ten_env_log(uintptr_t bridge_addr, int level, const void *func_name, int func_name_len, const void *file_name, int file_name_len, int line_no, const void *msg, diff --git a/core/src/ten_runtime/binding/go/interface/ten/ten_property.go b/core/src/ten_runtime/binding/go/interface/ten/ten_property.go index 8681270922..d71f52a017 100644 --- a/core/src/ten_runtime/binding/go/interface/ten/ten_property.go +++ b/core/src/ten_runtime/binding/go/interface/ten/ten_property.go @@ -690,16 +690,3 @@ func (p *tenEnv) InitPropertyFromJSONBytes(value []byte) error { return err } - -func (p *tenEnv) InitManifestFromJSONBytes(value []byte) error { - defer p.keepAlive() - - apiStatus := C.ten_go_ten_env_init_manifest_from_json_bytes( - p.cPtr, - unsafe.Pointer(unsafe.SliceData(value)), - C.int(len(value)), - ) - err := withGoStatus(&apiStatus) - - return err -} diff --git a/core/src/ten_runtime/binding/go/native/ten_env/ten_env_init_property.c b/core/src/ten_runtime/binding/go/native/ten_env/ten_env_init_property.c index ae63501046..90b5a2a54f 100644 --- a/core/src/ten_runtime/binding/go/native/ten_env/ten_env_init_property.c +++ b/core/src/ten_runtime/binding/go/native/ten_env/ten_env_init_property.c @@ -7,7 +7,6 @@ #include "include_internal/ten_runtime/binding/go/internal/common.h" #include "include_internal/ten_runtime/binding/go/ten_env/ten_env.h" #include "include_internal/ten_runtime/binding/go/ten_env/ten_env_internal.h" -#include "include_internal/ten_runtime/ten_env/metadata.h" #include "ten_runtime/binding/go/interface/ten/common.h" #include "ten_runtime/binding/go/interface/ten/ten_env.h" #include "ten_runtime/common/errno.h" @@ -68,21 +67,6 @@ static void ten_env_notify_init_property_from_json(ten_env_t *ten_env, ten_error_deinit(&err); } -static void ten_env_notify_init_manifest_from_json(ten_env_t *ten_env, - void *user_data) { - TEN_ASSERT(user_data, "Invalid argument."); - TEN_ASSERT(ten_env && ten_env_check_integrity(ten_env, true), - "Should not happen."); - - ten_env_notify_init_property_info_t *info = user_data; - TEN_ASSERT(info, "Should not happen."); - - ten_env_init_manifest_from_json(ten_env, ten_string_get_raw_str(&info->value), - &info->err); - - ten_event_set(info->completed); -} - ten_go_status_t ten_go_ten_env_init_property_from_json_bytes( uintptr_t bridge_addr, const void *json_str, int json_str_len) { ten_go_ten_env_t *self = ten_go_ten_env_reinterpret(bridge_addr); @@ -117,38 +101,3 @@ ten_go_status_t ten_go_ten_env_init_property_from_json_bytes( ten_is_close: return status; } - -ten_go_status_t ten_go_ten_env_init_manifest_from_json_bytes( - uintptr_t bridge_addr, const void *json_str, int json_str_len) { - ten_go_ten_env_t *self = ten_go_ten_env_reinterpret(bridge_addr); - TEN_ASSERT(self && ten_go_ten_env_check_integrity(self), - "Should not happen."); - - ten_go_status_t status; - ten_go_status_init_with_errno(&status, TEN_ERRNO_OK); - - TEN_GO_TEN_IS_ALIVE_REGION_BEGIN(self, { - ten_go_status_init_with_errno(&status, TEN_ERRNO_TEN_IS_CLOSED); - return status; - }); - - ten_env_notify_init_property_info_t *info = - ten_env_notify_init_property_info_create(json_str, json_str_len); - TEN_ASSERT(info, "Should not happen."); - - if (!ten_env_proxy_notify(self->c_ten_env_proxy, - ten_env_notify_init_manifest_from_json, info, false, - &info->err)) { - goto done; - } - - ten_event_wait(info->completed, -1); - -done: - ten_go_status_from_error(&status, &info->err); - ten_env_notify_init_property_info_destroy(info); - TEN_GO_TEN_IS_ALIVE_REGION_END(self); - -ten_is_close: - return status; -} diff --git a/tests/ten_runtime/integration/go/access_property_go/access_property_go_app/ten_packages/extension/default_extension_go/default_extension.go b/tests/ten_runtime/integration/go/access_property_go/access_property_go_app/ten_packages/extension/default_extension_go/default_extension.go index 0490883d5e..f6fb1ff069 100644 --- a/tests/ten_runtime/integration/go/access_property_go/access_property_go_app/ten_packages/extension/default_extension_go/default_extension.go +++ b/tests/ten_runtime/integration/go/access_property_go/access_property_go_app/ten_packages/extension/default_extension_go/default_extension.go @@ -43,35 +43,10 @@ type aExtension struct { baseExtension } -func (p *aExtension) OnConfigure(tenEnv ten.TenEnv) { - if err := tenEnv.InitManifestFromJSONBytes([]byte(`{ - "type": "extension", - "name": "A", - "version": "0.0.1", - "api": { - "property": { - "prop_int": { - "type": "int8" - } - } - } - }`)); err != nil { - panic("Should not happen.") - } - - tenEnv.OnConfigureDone() -} - func (p *aExtension) OnCmd( tenEnv ten.TenEnv, cmd ten.Cmd, ) { - if err := tenEnv.SetProperty("prop_int", false); err == nil { - panic("Should not happen, the schema is not matched.") - } else { - println("SetProperty failed: ", err.Error()) - } - if err := tenEnv.SetProperty("testBool", false); err != nil { panic("Should not happen.") }