Skip to content

Commit

Permalink
Fixes to the compact script mode
Browse files Browse the repository at this point in the history
  • Loading branch information
checkroom committed Nov 22, 2024
1 parent 456eaeb commit dc6ca0b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
10 changes: 4 additions & 6 deletions examples/demo-c.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@
<fl:button label="Add" on.callback="on_add" box="20,160,80,50" />
<fl:button label="Remove" on.callback="on_dec" box="120,160,80,50" />
<fl:button label="Console" box="220,160,80,50">
<script lang="c">
<![CDATA[
void callback(){
$log(LOG_LOG,"Hello world!");
}
]]>
<script lang="c" compact="true">
<![CDATA[
$log(LOG_LOG,"Hello world2!");
]]>
</script>
</fl:button>
</fl:window>
Expand Down
4 changes: 2 additions & 2 deletions src/pipelines/tcc-c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ std::shared_ptr<tcc> 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");
Expand Down Expand Up @@ -121,7 +121,7 @@ std::shared_ptr<tcc> tcc_c_pipeline(bool is_runtime, vs::ui_base* obj, const cha

if(compact){
script->compile_str_embedded(
"#include <vs.h>\n#include <stub.h>\n//#file embedded \nint callback(){\n#line 0\n", //TODO: Add custom header if linked with an external thing
"#include <vs.h>\n#include <stub.h>\n//#file embedded \nvoid callback(){\n#line 0\n", //TODO: Add custom header if linked with an external thing
src,
"\n}"
);
Expand Down
6 changes: 5 additions & 1 deletion src/ui-tree.xml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down

0 comments on commit dc6ca0b

Please sign in to comment.