* gg: pure-V sgl renderer (gg/render) with CPU rasterizer backend
* gg: add per-corner rounded rect, 9-slice, CPU output equality test
* gg: add multiply/screen blend modes to renderer and CPU rasterizer
* gg: add multiply/screen to ImageEffect enum
* gg: fix review defects in V renderer (font crash, api break, leaks)
- text_rendering: add FonsRenderTarget allocated before
fonsCreateInternal, since fontstash calls renderCreate
synchronously; fixes invalid memory access crash on startup.
renderUpdate now copies only the dirty atlas region.
- draw: rewrite draw_rounded_rect_filled_4 as a single convex
triangle strip (removes nonexistent begin_triangle_fan calls
that broke compilation of any user of the new API, removes
double-blend overlaps); add clamp_radius/clamp_slice helpers.
- draw_9slice: remove dead slices array/loop, clamp dest slices
proportionally, use clamped UVs.
- render: do not create pipeline object 5 (quads reuse triangles
pipeline, matching sgl); push_pipeline uses max_stack_depth-1;
add is_image_registered/update_image_region/destroy.
- image: register textures once per image; streaming updates
refresh the CPU copy via update_image_region.
- gg: call ctx.r.destroy() before gfx.shutdown(); drop unused
gg.render imports; add .vv compile samples for the new APIs.
- flush: pass [4]int dirty rect to validate_texture (was &int,
heap overwrite causing delayed crash in begin()).
* gg: migrate examples off sokol.sgl to ctx.r
gg no longer submits an sgl context after the pure-V renderer migration, so direct sgl calls in gg examples either failed to typecheck (rotating_textured_quad passed render.Pipeline to sgl.load_pipeline) or silently recorded nothing. Route matrix, pipeline, texture and primitive calls through ctx.r instead.
* x.ttf.render_sokol: draw through ctx.r instead of sgl
draw_text_bmp took ctx &gg.Context but issued its matrix, pipeline, texture and quad calls to sokol.sgl. After the pure-V renderer migration gg no longer submits an sgl context, and the mixed types made the function (and every ttf_font example) fail to compile: cannot use render.Pipeline as sgl.Pipeline in argument 1 to sgl.load_pipeline.
* gg: add a compile-test for all gg based examples
Compiles every examples/gg program, plus breakout, viewer and both ttf_font examples, so examples that keep referencing sokol.sgl directly fail the suite instead of the renderer migration (render.Pipeline is not sgl.Pipeline) going unnoticed. The samples are compiled in parallel with VJOBS-style workers into a private vcache directory.
* cgen: scope cleanup switch cases for older Apple Clang
* checker: let zero assignments leave reference sum variants
* math.big: pass signed byte counts to memory helpers
* checker: limit zero literal inspection to reference narrowing
* checker: stop loop narrowing scans before the current assignment
* tests: repair integer migration inputs for macOS self tests
* checker: return platform int for translated pointer differences
* examples: use signed byte counts for graphics buffers
* cgen: preserve headerless mmap bindings in cached modules
* fastc: repair pointer difference formatting and bootstrap fallback
* macos: fix CI formatting and older SDK TCC headers
* crdt: format gcounter tests for CI
* crdt: remove trailing blank lines caught by CI
* vfmt: format files reported by macOS CI
* veb.csrf: use context configuration when clearing cookies
* math: provide logf in pure V builds
* math: correctly round pure V square roots
* transform: preserve generic elements in fixed array loops
* cgen: escape bool field names for stdbool compatibility
* json2: release JSON5 decoding scratch and cloned map keys
* examples: use pointer recursion in the binary search tree
* modulecache: preserve static macro definitions in declaration headers
* macos: fix declaration test scanning and recursive tree example
* test-self: isolate compiler environment flags from nested builds
* cgen: preserve interface dispatch and module roots with warm caches
* tests: correct backend fixtures exercised by macOS CI
* transform: decode escaped bool generic arguments
* tests: align GC and closure checks with native declarations
* tests: match current HTML tag formatting in option output
* cgen: retain mutable struct addresses in integer casts
* transform: retain explicit generic method calls when ordering arguments
* checker: retain nested translated array types in pointer comparisons
* tests: retain type storage and canonicalize macOS temporary paths
* graphql: store recursive AST edges through pointers
* veb: avoid copying large request and response structs for connection checks
* veb.csrf: expire cleared cookies at the configured path
* veb: add typed controller-aware OpenAPI documents
* veb: fix OpenAPI ID collisions and field metadata
* veb: match OpenAPI schemas to dispatched routes and JSON encoding
* veb: align typed OpenAPI schemas with routing and JSON encoding
* sokol: fix sokol.audio on Windows TCC and fix simple_bytebeat example (fixes#30891)
- Fix TCC objbase.h bug where COINIT_MULTITHREADED is defined as 0x3 instead of 0x0, causing CoInitializeEx to fail with E_INVALIDARG and CoCreateInstance for IMMDeviceEnumerator to fail with CO_E_NOTINITIALIZED.
- Fix TCC missing 1-byte struct packing for WAVEFORMATEX / WAVEFORMATEXTENSIBLE, which caused IAudioClient_Initialize to fail with E_INVALIDARG.
- Fix simple_bytebeat.v user_data callback signature and frame count handling.
- Add sokol.audio setup/shutdown test in vlib/sokol/audio/audio_test.c.v.
* sokol: keep bytebeat frame state on the audio callback thread
---------
Co-authored-by: Alexander Medvednikov <alexander@medvednikov.com>
* vlib/json2: remove duplicated sumtype todo fixture
The todo file was copied into decoder_tests/ by a60fb589 while the
identical original stayed in tests/. Nothing references either copy
(they are uncompiled .vv notes), so drop the newer duplicate.
* examples: remove unreferenced duplicate veb_assets example
veb_assets_example.v is byte-identical to the sibling veb_assets.v and
referenced nowhere (docs, tests, CI). Keep the original, drop the copy.
---------
Co-authored-by: qp <168933756+gabytz777@users.noreply.github.com>
* doc: point hot code reloading at v watch, not v -live
The Hot code reloading section documented `v -live` with @[live]
functions as the way to iterate on a running program. That per-function
mechanism no longer reloads under the default compiler (#30198), while
`v watch` - rebuild and re-run on change, plus browser refresh for veb
apps via -d veb_livereload - is what the veb README documents and what
works today.
Make `v watch` the recommended flow in doc/docs.md, with the veb
options from the veb README, keep the @[live] mechanics under their own
heading with a note about the current status, and update the build
comments of the two hot_reload examples to the watch workflow.
Fixes#30355
* doc: explain restart state before legacy hot reload commands
---------
Co-authored-by: Alexander Medvednikov <alexander@medvednikov.com>
* image: add image.decoders with JPEG, PNG, BMP, WEBP, TIFF, GIF decoders
Add pure-V image decoders under vlib/image/decoders: one package per
format, a shared common module (Image/Frame/Animation/BitReader), and a
magic-byte dispatcher. Each codec package is self-contained with its own
tests and test data.
Replace examples/viewer with a viewer built on these decoders instead
of stbi, add a rewritten README, and document the decoders in
README.md, CODEC.md, and development.md.
* image.decoders: shrink the 4.webp fixture to 64x48
Resize the real-world animated WEBP fixture to 64x48 (lossy, alpha
kept) and update the pinned canvas size and FNV-1a checksums.
* examples/viewer: silence unused-function and interface-init notices
Remove the dead ci_less helper (name sorting already lowercases its
keys) and initialize App.player with a NullPlayer no-op implementation.
* image.decoders: shrink the jpeg base.jpg fixture to 256x320
* image.decoders: silence all compiler notices
- Write bit accumulation as x * (1 << k) instead of signed x << k in
the jpeg, tiff, and webp decoders (identical two's-complement
semantics, no sign-shift notice).
- Rename locals that shadow function declarations (hev_thr, copied).
- Prefix intentionally unused JPEG-spec parameters with _ in the
arithmetic decoder.
- Document the conventions in development.md.
* image.decoders: validate allocation sizes and TIFF block tables
* image: bound native buffers and release viewer animation ownership
* image.webp: release tracked arrays through builtin ownership headers
---------
Co-authored-by: Alexander Medvednikov <alexander@medvednikov.com>
* veb: render_request, so an app can render a route without a listener
`veb.run` starts a server, which is the only way to get a page out of a veb app
today. That is right for a server and wrong for a site that should be a directory
of files: a static export needs the same HTML without a process, a port, or a
second rendering implementation that can drift from the first.
`veb.render_request[A, X](mut app, req)` is one call that does it. It generates
the route table from the app's methods and dispatches the request through the
same `handle_request_and_route` the server loop uses. `Context.conn` stays nil and
`takeover_mode` stays `.none`, so `send_response_to_client` has nothing to write
to and the result is read from `ctx.res` by the caller.
It exists as one function rather than by making `generate_routes` and
`handle_request_and_route` public: those take a `RequestParams` whose fields are
veb internals (`routes: &map[string]Route`), and publishing that struct would
freeze a shape nobody should depend on. The public surface stays what it is plus
one entry - `RawHtml`, `Result`, `no_result()`, `run`, `Context.error`, and now
this.
This is not a new mechanism. veb's own suite has done exactly this by hand since
before this helper existed - `route_arguments_test.v`, `cors_before_request_test.v`,
`middleware_response_lifetime_test.v` and `controller_static_regression_test.v`
each build a `RequestParams` and call the dispatcher directly. Four call sites
reaching for the same private path is the argument for making it callable, not a
new feature.
`vlib/veb/vrender_test.v` covers the body, the 200, the 404 for an unknown path,
repeatability across calls, and - the load-bearing one - that `conn` stays nil.
A future change that started a listener would pass every other assertion in the
file, which is why it gets one of its own.
`examples/veb/static_export/` is a static site generator on top of it: an explicit
route list (a crawler follows links and silently skips pages whose only link is
generated at runtime), the URL-to-file mapping GitHub Pages serves directly, and a
count check so a page missing from `dist/` fails the build instead of shipping
short. `-prod` is used in the example for the reason it is used everywhere: a
template error becomes a build error.
Measured: `v test vlib/veb` is 17 passed / 24 skipped / 0 failed on Windows; the
24 skips are the ones needing a network or display, which CI runs. The example
exports 3 files and previews the same 3 pages through the listener.
* veb: validate and preserve listener-free request dispatch
* examples: correct static exporter invocation
* veb: validate render request context before dispatch
---------
Co-authored-by: metif12 <metif12@users.noreply.github.com>
Co-authored-by: Alexander Medvednikov <alexander@medvednikov.com>
* tools: make `v watch` build veb apps before restarting them
- Watch `templates/` and its subdirectories in veb projects. Templates are
compiled in, but the compiler does not report them, so a change to
`templates/layout/header.html` never triggered a rebuild.
- For veb apps, build the new executable while the old server keeps
serving, and swap them only when the build succeeds, so the app is down
only for the restart. A failed build leaves the old server running. A
change during a build cancels it and starts a new one, after a 150 ms
debounce. `--no-build-first` restores the previous behaviour.
- Write the build status (`building`, `failed` with the compiler output, or
`ok`) to a file named by VEB_LIVERELOAD_STATUS in the app's environment,
for veb's live reload. Print how long each build took.
- Stop the build and the program on SIGTERM and SIGHUP, as on Ctrl-C. They
run in their own process groups, so they kept running (and kept their
port) after `v watch` was terminated.
* veb: live reload over server-sent events, keeping page state
With `-d veb_livereload`:
- Replace the 250 ms polling with one Server-Sent Events stream per page,
held in a shared hub (no thread per tab), capped by
`-d veb_livereload_max_streams` (default 32). A keepalive ping every 15 s
drops closed tabs.
- After a restart, fetch the page again and morph the DOM in place, keeping
scroll position, focus, typed form values and page JS state. Pages from a
POST, failed fetches and non-HTML answers reload instead.
- Follow the files of a StaticHandler: a changed stylesheet is swapped in
place, other files update the page, with no rebuild.
- Relay the build status written by `v watch` (VEB_LIVERELOAD_STATUS): a
toast for rebuilding/updated, and a panel with the compiler output when a
build fails. `-d veb_livereload_no_toast` hides them.
- Reconnect every 250 ms; `-d veb_livereload_retry_max_ms` lets it back off.
- Keep the polling script behind `-d veb_livereload_polling`, for HTTPS apps
and for proxies that block long-lived connections, with its interval set
by `-d veb_livereload_poll_ms`. Deprecate the unused
`Context.livereload_poll_interval_ms`, which could never be set.
* examples, docs: update the veb live reload instructions
- examples/vwatch/web_server: put `-d veb_livereload` after `watch` (the
order before `watch` is currently dropped, see #30199), describe the new
live reload, and drop `--only-watch=*.v,*.html,*.css,*.js`, which is the
default for veb projects.
- v-veb skill: live reload is enabled by `-d veb_livereload` and applies to
any HTML response ending with `</html>`, not only to `$veb.html()` in
debug builds.
- veb blog tutorial: suggest `v watch -d veb_livereload run blog.v`, so the
open page updates too.
* veb: reload changed scripts and page resources
* veb: preserve typed values on their original form controls
---------
Co-authored-by: Alexander Medvednikov <alexander@medvednikov.com>
* docs: fix grammar mistakes in markdown files
Correct `its`/`it's`, verb-noun agreement, article and number
agreement errors in V-owned documentation.
vlib/x/encoding/asn1/DOCS.md: fix the bulk of the issues, including
`Its` -> `It`/`It is`/`This is`, `two form` -> `two forms`,
`four class` -> `four classes`, `a extra` -> `extra`, and
`you hope an universal type` -> `you need a universal type`.
Other files: single-grammar fixes in chacha20poly1305, ttf,
net/jsonrpc, vpbgen, bench/vectors and examples/templates READMEs.
Vendored thirdparty/ files and historical changelog entries are left
untouched, since the former are external code and the latter are
verbatim commit records.
No behavior change. `./v check-md` passes on all changed files.
* fix review feedback
---------
Co-authored-by: qp <168933756+gabytz777@users.noreply.github.com>
* pbgen: emit files that are already v fmt clean
A generated file that the formatter rewrites is a bug in the generator, not a
quirk of the generated code. Two things in the output were not what `v fmt`
produces, so every file this tool wrote reformatted itself the first time anyone
ran the formatter -- a `v git-fmt-hook`, a `v fmt -w`, an editor -- and that
reformat then landed as a diff nobody had written, in whatever repository held
the generated file.
`emit_message_struct` indented `pub mut:` by one level and its fields by two.
`v fmt` puts `pub mut:` at column 0 and its fields one level in, so the whole
struct body shifted on the first format. `write_generated` also ended on the
blank line an emitter naturally arrives at, where `v fmt` leaves exactly one
trailing newline.
Both are fixed at the source rather than by formatting after the fact. The
second one is trimmed in `write_generated` because every output path goes
through it, which also covers the `-grpc` output and the stdout case is
unaffected since it does not write a file.
`examples/grpc/README.md` loses its `v fmt -w` line as a result: there is no
format step to remember any more. Verified with a compiler built from this
tree, running the documented command and confirming the output survives `v fmt`
byte for byte.
The negative control: with these two changes reverted, the same command's output
does not survive `v fmt`.
test_write_generated_replaces_its_own_output expected the written bytes to equal
its input exactly, which the trailing-newline contract changes; it now asserts
the normalised form, and test_write_generated_normalises_trailing_newlines covers
the three trailing-newline shapes an emitter produces.
v -silent test cmd/tools/vpbgen/ 2 passed, 2 total
* pbgen: keep enum and service output formatter clean
---------
Co-authored-by: Alexander Medvednikov <alexander@medvednikov.com>
* net.grpc: add an experimental gRPC client and server
Ports the gRPC runtime from we-be/grpc.v into vlib as net.grpc, closing
most of vlang/v#5017. It covers the wire layer only: 5-byte message
framing, the grpc-status/grpc-message terminal status, per-call
metadata, a native gRPC client and server over net.http's HTTP/2 stack,
and a Connect-protocol server for connectrpc.com clients.
Messages cross the wire as []u8, so the module stays codec-agnostic and
pairs with any protobuf runtime (protobuf.v and vpbgen remain external
vmodules).
Two fixes against the ported original:
- Client.do_call must set FetchConfig.enable_http2. net.http reverted
HTTPS clients to HTTP/1.1 in #28996, so without it the client silently
degrades and never speaks gRPC. The doc comment claiming net.http
negotiates h2 on its own is corrected.
- Server wrappers now forward in_memory_verification, so TLS can be
driven from in-memory PEM strings.
Client and both servers also gained verify/cert/cert_key pass-through,
needed because V has no client-side h2c: a loopback gRPC round-trip has
to go through TLS.
Listed in vlib/.vdocignore as experimental. Streaming stays buffered
(one POST per direction) because net.http's Handler is one request in /
one response out.
* examples: add a net.grpc key-value example
An etcd-lite key-value service showing net.grpc end to end: all three
RPC shapes (unary, server streaming, client streaming), a typed
StatusError crossing the wire as a grpc-status trailer, a call carrying
a deadline and request metadata, and response/trailer metadata.
net.grpc is transport-only and moves []u8 payloads, so the example owns
its codec: kv/codec.v is a hand-written proto3 encoder/decoder for the
schema in kv.proto, with tests. That keeps the example free of external
dependencies, which v build-examples needs since it walks every
examples/**/*.v file that declares `module main`.
The TLS certificate is required rather than optional: gRPC is HTTP/2-only
and net.http negotiates h2 only for https, so even a loopback round-trip
has to speak TLS, as V has no client-side h2c path.
* net.grpc: preserve explicit status and ordered request metadata
---------
Co-authored-by: Alexander Medvednikov <alexander@medvednikov.com>
* net.http.signature: add HTTP Message Signatures (RFC 9421) module
* net.http.signature: pad ECDSA private scalar to curve width when parsing PEM
* net.http.signature: strip default ports from @authority per RFC 9421 §2.2.3
* net.http.signature: reconstruct absolute @target-uri for origin-form requests
* net.http.signature: gate the tests on OpenSSL, like the example and crypto.ecdsa
* net.http.signature: preserve canonical request inputs
* net.http.signature: harden request serialization
* net.http.signature: match transmitted request values
* net.http.signature: align request wire semantics
* net.http.signature: cover effective wire fields
* net.http.signature: validate signing inputs
* net.http.signature: finalize effective message fields
* net.http.signature: validate Ed25519 verification keys
* net.http.signature: validate effective responses
* net.http.signature: reject ambiguous signed messages
* net.http.signature: validate stable wire fields
* net.http.signature: handle remaining wire forms
* net.http.signature: canonicalize repeated inputs
* net.http.signature: validate structured metadata
* net.http.signature: preserve verified message values
* net.http.signature: align status and list parsing
* net.http.signature: tighten parameter parsing
* net.http.signature: preserve extension and empty values
* net.http.signature: preflight transport header changes
* net.http.signature: preserve covered cookie fields
* net.http.signature: trim derived host authority
* net.http.signature: enforce verification coverage
* net.http: preserve wire authorities
* net.http.signature: validate covered fields
* net.http.signature: preserve effective field values
* net.http.signature: enforce verification time bounds
* net.http.signature: align proxy and h2 coverage
* net.http.signature: protect response body defaults
* net.http.signature: protect request body defaults
* net.http.signature: reject invalid response status
* net.http: reject unframed trace bodies
* net.http.signature: load ECDSA public keys from raw coordinates
* net.http.signature: rename a local that collides with hash.crc32's q const
* net.http.signature: make the default digest policy independent of the received body
* net.http.signature: refuse to synthesize a forbidden Content-Length
* net.http.signature: run the tests on the default crypto backend
* net.http.signature: make the quick start verifiable
* net.http.signature: reformat structured_field.v with the current vfmt
* net.http.signature: sharpen the Content-Length diagnostics and document their limits
* net.http.signature: check header capacity at every step of the signing mutations
* net.http.signature: opt the HTTP/2 coverage tests into enable_http2
HTTPS requests default to HTTP/1.1 since #28996, so the tests for covered
fields that HTTP/2 negotiation would change have to enable HTTP/2 themselves.
* net.http: pass the remote address in the new h2 server test
serve_h2_conn takes the remote address since master's HTTP/2 server changes.
---------
Co-authored-by: Alexander Medvednikov <alexander@medvednikov.com>
Skipping unused functions has been the default for a while, so
`-skip-unused` was a no-op. Remove it from the driver, so passing it now
reports an unknown option, and drop it from `v complete`, the tests,
examples, tools and READMEs that still passed it.
The `-skip-unused` entry in `v help build` is replaced with one for
`-no-skip-unused`, the remaining way to opt out, which had no entry.
`int` is 64 bits wide on amd64, so the `r` constraints bind 64-bit
registers, and `mov eax, a` reached the assembler as `mov %rax, %eax`.
tcc accepted it, but gcc and clang reject the operand size mismatch
(`build_examples_clang` failed on examples/asm.v).