Skip to content

Commit

Permalink
feat: add on_configure
Browse files Browse the repository at this point in the history
  • Loading branch information
halajohn committed Sep 17, 2024
1 parent c03ea85 commit d8de77b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 17 deletions.
8 changes: 4 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -645,12 +645,12 @@
"name": "app (golang) (lldb, launch)",
"type": "lldb",
"request": "launch",
"program": "${workspaceFolder}/out/linux/x64/tests/ten_runtime/integration/python/go_app_python/go_app_python_app/bin/main",
"cwd": "${workspaceFolder}/out/linux/x64/tests/ten_runtime/integration/python/go_app_python/go_app_python_app/",
"program": "${workspaceFolder}/out/linux/x64/tests/ten_runtime/integration/go/access_property_go/access_property_go_app/bin/main",
"cwd": "${workspaceFolder}/out/linux/x64/tests/ten_runtime/integration/go/access_property_go/access_property_go_app/",
"env": {
"LD_LIBRARY_PATH": "${workspaceFolder}/out/linux/x64/tests/ten_runtime/integration/python/go_app_python/go_app_python_app/ten_packages/system/ten_runtime/lib:${workspaceFolder}/out/linux/x64/tests/ten_runtime/integration/python/go_app_python/go_app_python_app/ten_packages/system/ten_runtime_go/lib:${workspaceFolder}/out/linux/x64/tests/ten_runtime/integration/python/go_app_python/go_app_python_app/ten_packages/system/ten_runtime_python/lib",
"LD_LIBRARY_PATH": "${workspaceFolder}/out/linux/x64/tests/ten_runtime/integration/go/access_property_go/access_property_go_app/ten_packages/system/ten_runtime/lib:${workspaceFolder}/out/linux/x64/tests/ten_runtime/integration/go/access_property_go/access_property_go_app/ten_packages/system/ten_runtime_go/lib:${workspaceFolder}/out/linux/x64/tests/ten_runtime/integration/go/access_property_go/access_property_go_app/ten_packages/system/ten_runtime_go/lib",
"DYLD_LIBRARY_PATH": "${workspaceFolder}/out/linux/x64/tests/ten_runtime/integration/go/access_property_go/access_property_goo_app/lib",
"CGO_LDFLAGS": "-L${workspaceFolder}/out/linux/x64/tests/ten_runtime/integration/python/go_app_python/go_app_python_app/ten_packages/system/ten_runtime_go/lib -lten_runtime_go -Wl,-rpath,@loader_path/lib -Wl,-rpath,@loader_path/../lib",
"CGO_LDFLAGS": "-L${workspaceFolder}/out/linux/x64/tests/ten_runtime/integration/go/access_property_go/access_property_go_app/ten_packages/system/ten_runtime_go/lib -lten_runtime_go -Wl,-rpath,@loader_path/lib -Wl,-rpath,@loader_path/../lib",
"TEN_ENABLE_PYTHON_DEBUG": "true",
},
"initCommands": [
Expand Down
1 change: 0 additions & 1 deletion core/src/ten_runtime/binding/go/native/app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ static void proxy_on_init(ten_app_t *app, ten_env_t *ten_env) {
TEN_ASSERT(app_bridge, "Should not happen.");

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);

tenGoAppOnInit(app_bridge->bridge.go_instance,
ten_go_ten_env_go_handle(ten_bridge));
Expand Down
3 changes: 1 addition & 2 deletions core/src/ten_runtime/binding/go/native/ten_env/ten_env_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,9 @@ void ten_go_ten_env_log(uintptr_t bridge_addr, int level, const void *func_name,
false, &err)) {
goto done;
}
ten_event_wait(info->completed, -1);
}

ten_event_wait(info->completed, -1);

done:
ten_error_deinit(&err);
ten_env_notify_log_info_destroy(info);
Expand Down
2 changes: 1 addition & 1 deletion core/src/ten_runtime/binding/python/native/app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ static PyObject *ten_py_app_create(PyTypeObject *type, PyObject *args,
return ten_py_raise_py_type_error_exception("Expect 0 argument.");
}

py_app->c_app = ten_app_create(proxy_on_init, proxy_on_deinit, NULL);
py_app->c_app = ten_app_create(NULL, proxy_on_init, proxy_on_deinit, NULL);
if (!py_app->c_app) {
TEN_ASSERT(0, "Failed to create TEN app.");

Expand Down
14 changes: 5 additions & 9 deletions core/src/ten_runtime/binding/python/native/extension/extension.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,12 @@ static void proxy_on_init(ten_extension_t *extension, ten_env_t *ten_env) {
py_extension && ten_py_extension_check_integrity(py_extension, true),
"Invalid argument.");

ten_py_ten_env_t *py_ten_env = ten_py_ten_wrap(ten_env);
py_extension->py_ten_env = (PyObject *)py_ten_env;

py_ten_env->c_ten_env_proxy = ten_env_proxy_create(ten_env, 1, NULL);
TEN_ASSERT(py_ten_env->c_ten_env_proxy &&
ten_env_proxy_check_integrity(py_ten_env->c_ten_env_proxy),
"Invalid argument.");
PyObject *py_ten_env = py_extension->py_ten_env;
TEN_ASSERT(py_ten_env, "Should not happen.");

PyObject *py_res = PyObject_CallMethod((PyObject *)py_extension, "on_init",
"O", py_ten_env->actual_py_ten_env);
PyObject *py_res =
PyObject_CallMethod((PyObject *)py_extension, "on_init", "O",
((ten_py_ten_env_t *)py_ten_env)->actual_py_ten_env);
Py_XDECREF(py_res);

bool err_occurred = ten_py_check_and_clear_py_error();
Expand Down

0 comments on commit d8de77b

Please sign in to comment.