refactor: rename DTree to DValue

This commit is contained in:
udo
2026-06-12 11:05:52 +00:00
parent 941f5aea08
commit 7066da3cde
157 changed files with 1203 additions and 1074 deletions
+24 -24
View File
@@ -18,7 +18,7 @@ const char* UCE_CLI_SYMBOL = "__uce_cli";
const char* UCE_SERVE_HTTP_SYMBOL = "__uce_serve_http";
const char* UCE_ONCE_SYMBOL = "__uce_once";
const char* UCE_INIT_SYMBOL = "__uce_init";
const u64 UCE_UNIT_ABI_VERSION = 5;
const u64 UCE_UNIT_ABI_VERSION = 6;
struct SharedUnitFilesystemState
{
@@ -575,21 +575,21 @@ String compiler_unit_exports_text(SharedUnit* su)
return(trim(file_get_contents(su->api_file_name)));
}
void compiler_tree_push_string(DTree& tree, String value)
void compiler_tree_push_string(DValue& tree, String value)
{
DTree item;
DValue item;
item = value;
tree.push(item);
}
void compiler_tree_push_strings(DTree& tree, StringList values)
void compiler_tree_push_strings(DValue& tree, StringList values)
{
tree.set_array();
for(auto& value : values)
compiler_tree_push_string(tree, value);
}
void compiler_tree_set_bool(DTree& tree, String key, bool value)
void compiler_tree_set_bool(DValue& tree, String key, bool value)
{
tree[key].set_bool(value);
}
@@ -995,7 +995,7 @@ SharedUnit* compiler_load_shared_unit(Request* context, String file_name, String
printf("%s\n", display_messages.c_str());
if(compiler_can_write_response(context) && context->stats.invoke_count == 1)
{
DTree error_info;
DValue error_info;
error_info["type"] = "compiler_error";
error_info["status"] = su->compile_status;
error_info["source"] = su->file_name;
@@ -1124,9 +1124,9 @@ bool compiler_unit_needs_recompile(Request* context, String file_name, bool* sou
return(compile_check.needs_compile);
}
DTree unit_info(String path)
DValue unit_info(String path)
{
DTree info;
DValue info;
if(!context)
return(info);
@@ -1303,9 +1303,9 @@ struct UnitCallMacroTarget
struct RequestPropsScope
{
Request* context = 0;
DTree previous_props;
DValue previous_props;
RequestPropsScope(Request* context, const DTree& props)
RequestPropsScope(Request* context, const DValue& props)
{
this->context = context;
if(this->context)
@@ -1766,7 +1766,7 @@ String compiler_error_page_unit(Request* context, String config_key)
return(resolved);
}
bool compiler_render_error_page(Request* context, String config_key, s32 status_code, String status_reason, DTree error_info)
bool compiler_render_error_page(Request* context, String config_key, s32 status_code, String status_reason, DValue error_info)
{
if(!compiler_can_write_response(context))
return(false);
@@ -1840,7 +1840,7 @@ void compiler_invoke(Request* context, String file_name)
if(resolved != "" && compiler_unit_compile_pending(context, resolved))
{
compiler_track_known_unit(context, resolved);
DTree error_info;
DValue error_info;
error_info["type"] = "compiling";
error_info["source"] = resolved;
if(compiler_render_error_page(context, "page_compiling", 503, "UCE Unit Compiling", error_info))
@@ -1963,22 +1963,22 @@ String component_error_banner(String message)
void component_render(String name)
{
DTree props;
DValue props;
component_render(name, props, *context);
}
void component_render(String name, Request& context)
{
DTree props;
DValue props;
component_render(name, props, context);
}
void component_render(String name, DTree props)
void component_render(String name, DValue props)
{
component_render(name, props, *context);
}
void component_render(String name, DTree props, Request& context)
void component_render(String name, DValue props, Request& context)
{
String file_name;
String render_name;
@@ -2000,22 +2000,22 @@ void component_render(String name, DTree props, Request& context)
String component(String name)
{
DTree props;
DValue props;
return(component(name, props, *context));
}
String component(String name, Request& context)
{
DTree props;
DValue props;
return(component(name, props, context));
}
String component(String name, DTree props)
String component(String name, DValue props)
{
return(component(name, props, *context));
}
String component(String name, DTree props, Request& context)
String component(String name, DValue props, Request& context)
{
ob_start();
component_render(name, props, context);
@@ -2035,9 +2035,9 @@ SharedUnit* unit_load(String file_name)
}
}
DTree* unit_call(String file_name, String function_name, DTree* call_param)
DValue* unit_call(String file_name, String function_name, DValue* call_param)
{
DTree* result = 0;
DValue* result = 0;
auto su = compiler_load_shared_unit(context, file_name, "", false);
if(su && su->so_handle)
{
@@ -2050,7 +2050,7 @@ DTree* unit_call(String file_name, String function_name, DTree* call_param)
auto macro_target = unit_call_macro_target(function_name);
if(macro_target.kind != UnitCallMacroKind::none)
{
RequestPropsScope props_scope(context, (call_param ? *call_param : DTree()));
RequestPropsScope props_scope(context, (call_param ? *call_param : DValue()));
String error_message = "";
if(macro_target.kind == UnitCallMacroKind::render)
@@ -2094,7 +2094,7 @@ DTree* unit_call(String file_name, String function_name, DTree* call_param)
}
else
{
auto f = (dtree_call_handler)dlsym(su->so_handle, function_name.c_str());
auto f = (dv_call_handler)dlsym(su->so_handle, function_name.c_str());
if(!f)
{
print("Error: unit_call() function '", function_name, "' not found");