From dc6ca0b19385231a6b08421d183dc2d58854a062 Mon Sep 17 00:00:00 2001 From: checkroom Date: Fri, 22 Nov 2024 17:42:28 +0000 Subject: [PATCH] Fixes to the compact script mode --- examples/demo-c.xml | 10 ++++------ src/pipelines/tcc-c.cpp | 4 ++-- src/ui-tree.xml.cpp | 6 +++++- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/examples/demo-c.xml b/examples/demo-c.xml index 90f9bee..cc1320a 100644 --- a/examples/demo-c.xml +++ b/examples/demo-c.xml @@ -31,12 +31,10 @@ - diff --git a/src/pipelines/tcc-c.cpp b/src/pipelines/tcc-c.cpp index 244d2fe..1a415c6 100644 --- a/src/pipelines/tcc-c.cpp +++ b/src/pipelines/tcc-c.cpp @@ -47,8 +47,8 @@ std::shared_ptr tcc_c_pipeline(bool is_runtime, vs::ui_base* obj, const cha script->add_lib_path("./subprojects/libtcc"); script->set_out_type(tcc::memory); + script->add_sysinclude_path((globals::path_env.root.location+"./bindings/native/tcc/include").c_str()); - script->add_include_path((globals::path_env.root.location+"./bindings/native/include").c_str()); //script->add_lib("ld"); @@ -121,7 +121,7 @@ std::shared_ptr tcc_c_pipeline(bool is_runtime, vs::ui_base* obj, const cha if(compact){ script->compile_str_embedded( - "#include \n#include \n//#file embedded \nint callback(){\n#line 0\n", //TODO: Add custom header if linked with an external thing + "#include \n#include \n//#file embedded \nvoid callback(){\n#line 0\n", //TODO: Add custom header if linked with an external thing src, "\n}" ); diff --git a/src/ui-tree.xml.cpp b/src/ui-tree.xml.cpp index bf17e5d..559c28b 100755 --- a/src/ui-tree.xml.cpp +++ b/src/ui-tree.xml.cpp @@ -377,7 +377,6 @@ void ui_xml_tree::_build_base_widget_extended_attr(const pugi::xml_node &root, u auto script_type=root.attribute("type").as_string(""); auto compact=root.attribute("mode").as_bool(false); - if(compact)current->apply_prop("on.callback", "callback"); //Check if it is a module or single user; if module check for cache and use it. if(strcmp(script_type,"module")==0){ @@ -390,6 +389,7 @@ void ui_xml_tree::_build_base_widget_extended_attr(const pugi::xml_node &root, u current->attach_script(((cache::script_t*)found->ref.get())->script,is_module); current->set_symbols(((cache::script_t*)found->ref.get())->symbols); + if(compact)current->apply_prop("on.callback", "callback"); //All done, precomputed and rightfully applied! continue; } @@ -430,6 +430,8 @@ void ui_xml_tree::_build_base_widget_extended_attr(const pugi::xml_node &root, u globals::mem_storage.fetch_from_shared({this->fullname.as_string().c_str(),local_unique_counter+1,cache::resource_t::SCRIPT,false,false}, tmp); local_unique_counter++; } + + if(compact)current->apply_prop("on.callback", "callback"); } continue; } @@ -450,6 +452,8 @@ void ui_xml_tree::_build_base_widget_extended_attr(const pugi::xml_node &root, u globals::mem_storage.fetch_from_shared({this->fullname.as_string().c_str(),local_unique_counter+1,cache::resource_t::SCRIPT,false,false}, tmp); local_unique_counter++; } + + if(compact)current->apply_prop("on.callback", "callback"); } continue; }