getting closer to full port of web app starter
This commit is contained in:
@@ -64,9 +64,8 @@ Whether the request should be logged
|
||||
f64 stats.time_start
|
||||
f64 stats.time_end
|
||||
|
||||
:render_file(String file_name, [Request& context])
|
||||
:unit_render(String file_name, [Request& context])
|
||||
Invokes another UCE file using the current or supplied request context
|
||||
|
||||
:see
|
||||
>types
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ COMPONENT(Request& context)
|
||||
:desc
|
||||
Defines the default component entrypoint for the current `.uce` file.
|
||||
|
||||
`component()` and `render_component()` invoke `COMPONENT(Request& context)` by default. Named component entrypoints use `COMPONENT:NAME(Request& context)`.
|
||||
`component()` and `component_render()` invoke `COMPONENT(Request& context)` by default. Named component entrypoints use `COMPONENT:NAME(Request& context)`.
|
||||
|
||||
This keeps page rendering and component rendering separate:
|
||||
|
||||
@@ -16,7 +16,7 @@ A file intended only for component reuse can define `COMPONENT()` without defini
|
||||
|
||||
Inside component handlers, props arrive through `context.call`.
|
||||
|
||||
When you call `component(":NAME", props, context)` or `render_component(":NAME", props, context)`, the runtime resolves `:NAME` against the current `.uce` file instead of requiring the file name again.
|
||||
When you call `component(":NAME", props, context)` or `component_render(":NAME", props, context)`, the runtime resolves `:NAME` against the current `.uce` file instead of requiring the file name again.
|
||||
|
||||
Examples:
|
||||
`COMPONENT(Request& context)`
|
||||
@@ -31,6 +31,6 @@ Examples:
|
||||
|
||||
:see
|
||||
>component
|
||||
>render_component
|
||||
>component_render
|
||||
>1_RENDER
|
||||
>1_WS
|
||||
|
||||
@@ -14,7 +14,7 @@ The request environment is passed explicitly through `context`, including params
|
||||
|
||||
For a normal direct page request, `context.call` starts empty.
|
||||
|
||||
If the page is invoked from another UCE file via `render_file(file_name, context)`, the callee receives that same `context`.
|
||||
If the page is invoked from another UCE file via `unit_render(file_name, context)`, the callee receives that same `context`.
|
||||
|
||||
Pages intended to serve WebSocket traffic may expose both `RENDER(Request& context)` and `WS(Request& context)`. Files may also define `COMPONENT()` handlers when they intentionally need both page and component behavior in one unit. In that case `RENDER(Request& context)` serves the direct HTTP response, `WS(Request& context)` handles subsequent WebSocket messages, and `COMPONENT()` remains available only through the component helpers.
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ The loaded file is resolved relative to the current source file unless the path
|
||||
- `#load` is recognized only when the current line starts with `#load ` at column 1.
|
||||
- `EXPORT` harvesting likewise only triggers when the current line starts with `EXPORT` at column 1 and is followed by whitespace.
|
||||
- Relative `#load` paths are expanded against the including unit's source directory.
|
||||
- `render_file()` and `call_file()` are runtime APIs; `#load` is a compile-time include/composition feature.
|
||||
- `unit_render()` and `unit_call()` are runtime APIs; `#load` is a compile-time include/composition feature.
|
||||
|
||||
:Limitations
|
||||
- This pass is character-wise, not a full parser.
|
||||
@@ -92,7 +92,7 @@ The loaded file is resolved relative to the current source file unless the path
|
||||
|
||||
:see
|
||||
load
|
||||
render_file
|
||||
call_file
|
||||
unit_render
|
||||
unit_call
|
||||
0_context
|
||||
1_COMPONENT
|
||||
|
||||
@@ -12,7 +12,7 @@ Common uses include:
|
||||
`json_decode()` / `json_encode()`
|
||||
`context.var`
|
||||
`context.call`
|
||||
`call_file()` return values
|
||||
`unit_call()` return values
|
||||
|
||||
Useful methods include:
|
||||
`to_string()`
|
||||
|
||||
@@ -8,7 +8,7 @@ Renders another `.uce` file as a component and returns the captured output as a
|
||||
|
||||
Component props are passed in `context.call`.
|
||||
|
||||
Because `<?= ... ?>` HTML-escapes its value, embed component markup with `<?: component(...) ?>`, `print(component(...))`, or use `render_component(...)` for direct output.
|
||||
Because `<?= ... ?>` HTML-escapes its value, embed component markup with `<?: component(...) ?>`, `print(component(...))`, or use `component_render(...)` for direct output.
|
||||
|
||||
When `name` contains a colon, such as `components/card:BODY`, the part after the colon selects a named component handler exported from the component file through `COMPONENT:BODY(Request& context)`.
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
:sig
|
||||
void render_component(String name, [DTree props], [Request& context])
|
||||
void component_render(String name, [DTree props], [Request& context])
|
||||
|
||||
:desc
|
||||
Renders another `.uce` file as a component and writes the result directly to the current output buffer.
|
||||
@@ -10,12 +10,12 @@ Component props are passed through `context.call`, and `name:COMPONENTFUNC` may
|
||||
|
||||
When `name` starts with `:`, the runtime resolves that named handler against the current `.uce` file.
|
||||
|
||||
Use `render_component()` when you want to write component output directly from C++ code instead of capturing it as a `String`.
|
||||
Use `component_render()` when you want to write component output directly from C++ code instead of capturing it as a `String`.
|
||||
|
||||
Example:
|
||||
`DTree props;`
|
||||
`props["body"] = "Hello";`
|
||||
`render_component("components/card:BODY", props, context);`
|
||||
`component_render("components/card:BODY", props, context);`
|
||||
|
||||
:see
|
||||
>ob
|
||||
@@ -1,5 +1,5 @@
|
||||
:sig
|
||||
String get_cwd()
|
||||
String cwd_get()
|
||||
|
||||
:params
|
||||
return value : the current working directory
|
||||
@@ -1,5 +1,5 @@
|
||||
:sig
|
||||
void set_cwd(String path)
|
||||
void cwd_set(String path)
|
||||
|
||||
:params
|
||||
path : the new working directory
|
||||
@@ -0,0 +1,11 @@
|
||||
:sig
|
||||
void file_unlink(String file_name)
|
||||
|
||||
:params
|
||||
file_name : name of the file
|
||||
|
||||
:desc
|
||||
Deletes the file identified by `file_name`.
|
||||
|
||||
:see
|
||||
>sys
|
||||
@@ -72,6 +72,6 @@ The parser preserves directive data needed by those hooks.
|
||||
:see
|
||||
markdown_to_html
|
||||
component
|
||||
render_component
|
||||
component_render
|
||||
json_encode
|
||||
DTree
|
||||
|
||||
@@ -95,6 +95,6 @@ This makes directive components a good fit for alerts, callouts, cards, embeds,
|
||||
:see
|
||||
markdown_to_ast
|
||||
component
|
||||
render_component
|
||||
component_render
|
||||
json_decode
|
||||
String
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
:sig
|
||||
String make_session_id()
|
||||
String session_id_create()
|
||||
|
||||
:params
|
||||
return value : a new session ID
|
||||
|
||||
:desc
|
||||
Creates a session ID
|
||||
Creates a session ID.
|
||||
|
||||
:see
|
||||
>session
|
||||
@@ -1,5 +1,5 @@
|
||||
:sig
|
||||
s64 kill(pid_t pid, s64 sig)
|
||||
int task_kill(pid_t pid, int sig = 0)
|
||||
|
||||
:params
|
||||
pid : PID of the process
|
||||
@@ -7,7 +7,7 @@ sig : signal number
|
||||
return value : 0 if signal was sent, -1 otherwise
|
||||
|
||||
:desc
|
||||
This is the standard POSIX kill() function, provided here for reference.
|
||||
Wraps the standard POSIX `kill()` function.
|
||||
|
||||
Possible signal numbers are: SIGABND, SIGABRT, SIGALRM, SIGBUS, SIGFPE, SIGHUP, SIGILL, SIGINT, SIGKILL, SIGPIPE, SIGPOLL, SIGPROF, SIGQUIT, SIGSEGV, SIGSYS, SIGTERM, SIGTRAP, SIGURG, SIGUSR1, SIGUSR2, SIGVTALRM, SIGXCPU, SIGXFSZ, SIGCHLD, SIGIO, SIGIOERR, SIGWINCH, SIGSTOP, SIGTSTP, SIGTTIN, SIGTTOU, SIGCONT.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
:sig
|
||||
String date(String format = "", u64 timestamp = 0)
|
||||
String time_format_local(String format = "", u64 timestamp = 0)
|
||||
|
||||
:params
|
||||
format : formatting string specifying the date format
|
||||
@@ -1,5 +1,5 @@
|
||||
:sig
|
||||
String gmdate(String format = "", u64 timestamp = 0)
|
||||
String time_format_utc(String format = "", u64 timestamp = 0)
|
||||
|
||||
:params
|
||||
format : formatting string specifying the date format
|
||||
@@ -1,5 +1,5 @@
|
||||
:sig
|
||||
u64 parse_time(String time_string)
|
||||
u64 time_parse(String time_string)
|
||||
|
||||
:params
|
||||
time_string : a string containing a date and/or time in text form
|
||||
@@ -1,5 +1,5 @@
|
||||
:sig
|
||||
f64 microtime()
|
||||
f64 time_precise()
|
||||
|
||||
:params
|
||||
return value : current Unix timestamp
|
||||
@@ -1,5 +1,5 @@
|
||||
:sig
|
||||
DTree* call_file(String file_name, String function_name, DTree* call_param = null)
|
||||
DTree* unit_call(String file_name, String function_name, DTree* call_param = null)
|
||||
|
||||
:params
|
||||
file_name : UCE file to load and execute
|
||||
@@ -8,16 +8,17 @@ call_param : optional, call parameter
|
||||
return value : DTree* returned from function
|
||||
|
||||
:desc
|
||||
Calls a function inside a UCE file.
|
||||
Calls an exported function inside a UCE file.
|
||||
|
||||
:Example
|
||||
// export a function
|
||||
EXPORT void test_func()
|
||||
EXPORT DTree* test_func(DTree* call_param)
|
||||
{
|
||||
print("HELLO FROM TEST FUNCTION");
|
||||
return(0);
|
||||
}
|
||||
// use that function in another file
|
||||
call_file("call_file_funcs.uce", "test_func");
|
||||
unit_call("call_file_funcs.uce", "test_func");
|
||||
|
||||
:see
|
||||
>ob
|
||||
@@ -0,0 +1,15 @@
|
||||
:sig
|
||||
bool unit_compile(String path = "")
|
||||
|
||||
:params
|
||||
path : optional UCE unit path. If empty, recompiles the current executing unit.
|
||||
return value : `true` when the unit was compiled and loaded successfully
|
||||
|
||||
:desc
|
||||
Triggers a manual recompile of a UCE compilation unit.
|
||||
|
||||
If `path` is relative, it is resolved relative to the current executing unit. Successful manual compiles also refresh the in-memory metadata for that unit.
|
||||
|
||||
:see
|
||||
unit_info
|
||||
units_list
|
||||
@@ -0,0 +1,27 @@
|
||||
:sig
|
||||
DTree unit_info(String path = "")
|
||||
|
||||
:params
|
||||
path : optional UCE unit path. If empty, uses the current executing unit.
|
||||
return value : metadata tree for the resolved unit, or an empty tree if the unit cannot be resolved
|
||||
|
||||
:desc
|
||||
Returns runtime metadata for a UCE compilation unit.
|
||||
|
||||
The returned tree includes:
|
||||
|
||||
- normalized paths and generated artifact paths
|
||||
- compile status, compile error status, runtime error status, and a combined `error_status`
|
||||
- request and invocation counters
|
||||
- best, worst, last, and average render time
|
||||
- compile counters plus best, worst, last, and average compile time
|
||||
- file mtimes, stale status, load status, and exported API declarations
|
||||
|
||||
If `path` is relative, it is resolved relative to the current executing unit.
|
||||
|
||||
Because unit metadata lives in process memory alongside `SharedUnit`, request and timing counters reflect the current runtime process, not an aggregate across every worker process.
|
||||
|
||||
:see
|
||||
units_list
|
||||
unit_compile
|
||||
0_context
|
||||
@@ -0,0 +1,16 @@
|
||||
:sig
|
||||
SharedUnit* unit_load(String file_name)
|
||||
|
||||
:params
|
||||
file_name : UCE file to load
|
||||
return value : loaded shared unit, or `null` if the unit could not be loaded
|
||||
|
||||
:desc
|
||||
Loads a UCE compilation unit and returns its in-memory `SharedUnit` record.
|
||||
|
||||
This is a low-level runtime helper. Most application code should prefer `unit_render()`, `unit_call()`, `component()`, or `component_render()`.
|
||||
|
||||
:see
|
||||
unit_render
|
||||
unit_call
|
||||
load
|
||||
@@ -1,6 +1,6 @@
|
||||
:sig
|
||||
void render_file(String file_name)
|
||||
void render_file(String file_name, Request& context)
|
||||
void unit_render(String file_name)
|
||||
void unit_render(String file_name, Request& context)
|
||||
|
||||
:params
|
||||
file_name : UCE file to load and execute
|
||||
@@ -13,10 +13,10 @@ If `context` is omitted, the current active request context is used.
|
||||
|
||||
:Example
|
||||
// call a common page template
|
||||
render_file("page-template.uce");
|
||||
unit_render("page-template.uce");
|
||||
|
||||
// explicitly pass a request context
|
||||
render_file("page-template.uce", context);
|
||||
unit_render("page-template.uce", context);
|
||||
|
||||
:see
|
||||
>ob
|
||||
@@ -0,0 +1,11 @@
|
||||
:sig
|
||||
std::vector<String> units_list()
|
||||
|
||||
:desc
|
||||
Returns the normalized paths of all known `.uce` units.
|
||||
|
||||
This includes the shared known-unit registry plus any units already loaded in the current runtime process.
|
||||
|
||||
:see
|
||||
unit_info
|
||||
unit_compile
|
||||
@@ -1,11 +0,0 @@
|
||||
:sig
|
||||
void unlink(String file_name)
|
||||
|
||||
:params
|
||||
file_name : name of the file
|
||||
|
||||
:desc
|
||||
Deletes the file identified by 'file_name'.
|
||||
|
||||
:see
|
||||
>sys
|
||||
Reference in New Issue
Block a user