Docs, compatibility fixes again, 0.1 release

This commit is contained in:
Yorhel 2025-02-25 17:01:18 +01:00
parent 69262992ca
commit 7b0ba45346
15 changed files with 121 additions and 15 deletions

2
ChangeLog Normal file
View file

@ -0,0 +1,2 @@
0.1 - 2025-02-25
- Initial release

8
FU.pm
View file

@ -819,6 +819,14 @@ __END__
FU - Framework Ultimatum: A Lean and Efficient Zero-Dependency Web Framework.
=head1 EXPERIMENTAL
This module is still in development: it's missing important functionality and
there will likely be a few breaking API changes. This framework currently
powers manned.org as a test. I'll do a stable 1.0 release once FU is used in
production for vndb.org, which will take a few months in the best case
scenario.
=head1 SYNOPSIS
use v5.36;

6
FU.xs
View file

@ -95,7 +95,7 @@ void to_bool(SV *val)
PROTOTYPE: $
CODE:
SvGETMAGIC(val);
int r = fu_2bool(val);
int r = fu_2bool(aTHX_ val);
ST(0) = r < 0 ? &PL_sv_undef : r ? &PL_sv_yes : &PL_sv_no;
void json_format(SV *val, ...)
@ -399,14 +399,14 @@ void _new()
void _done(fuxmlwr *wr)
CODE:
ST(0) = fustr_done(&wr->out);
fustr_init(aTHX_ &wr->out, NULL, SIZE_MAX);
fustr_init(&wr->out, NULL, SIZE_MAX);
void lit_(SV *sv)
CODE:
if (!fuxmlwr_tail) fu_confess("No active FU::XMLWriter instance");
STRLEN len;
const char *buf = SvPVutf8(sv, len);
fustr_write(aTHX_ &fuxmlwr_tail->out, buf, len);
fustr_write(&fuxmlwr_tail->out, buf, len);
void txt_(SV *sv)
CODE:

View file

@ -65,6 +65,11 @@ __END__
FU::Log - Extremely Basic Process-Wide Logging Infrastructure
=head1 EXPERIMENTAL
This module is still in development and there will likely be a few breaking API
changes, see the main L<FU> module for details.
=head1 SYNOPSIS
use FU::Log 'log_write';

View file

@ -28,6 +28,11 @@ __END__
FU::Pg - The Ultimate (synchronous) Interface to PostgreSQL
=head1 EXPERIMENTAL
This module is still in development and there will likely be a few breaking API
changes, see the main L<FU> module for details.
=head1 SYNOPSYS
use FU::Pg;
@ -40,7 +45,7 @@ FU::Pg - The Ultimate (synchronous) Interface to PostgreSQL
$conn->q('INSERT INTO books (title) VALUES ($1)', 'The Invincible')->exec;
for my ($id, $title) ($conn->q('SELECT * FROM books')->flat->@*) {
print "$id: $title\n";
print "$id: $title\n";
}
=head1 DESCRIPTION
@ -628,7 +633,65 @@ I<TODO:> Custom per-type configuration.
=head2 Errors
I<TODO>
All methods can throw an exception on error. When possible, the error message
is constructed using L<Carp>'s C<confess()>, including a full stack trace.
SQL errors and other errors from I<libpq> are reported with a C<FU::Pg::error>
object, which has the following fields:
=over
=item action
The action that was attempted, "connect", "prepare" or "exec".
=item query
The query that was being prepared or executed, if any.
=item message
Human-readable error message.
=item verbose_message
More verbose message, usually consisting of multiple lines.
=item severity
=item detail
=item hint
=item statement_position
=item internal_position
=item internal_query
=item context
=item schema_name
=item table_name
=item column_name
=item datatype_name
=item constraint_name
=item source_file
=item source_line
=item source_function
These correspond to error fields from
L<PQresultErrorField()|https://www.postgresql.org/docs/current/libpq-exec.html#LIBPQ-PQRESULTERRORFIELD>.
=back
=head1 LIMITATIONS

View file

@ -2,7 +2,7 @@ package FU::SQL 0.1;
use v5.36;
use Exporter 'import';
use Carp 'confess';
use experimental 'builtin';
use experimental 'builtin', 'for_list';
our @EXPORT = qw/
P RAW SQL
@ -103,6 +103,11 @@ __END__
FU::SQL - Small and Safe SQL Query Builder
=head1 EXPERIMENTAL
This module is still in development and there will likely be a few breaking API
changes, see the main L<FU> module for details.
=head1 SYNOPSIS
use FU::SQL;

View file

@ -98,6 +98,11 @@ a core Perl installation but aren't for some reason because the Perl community
doesn't believe in the concept of a "batteries included" standard library.
</rant>
=head1 EXPERIMENTAL
This module is still in development and there will likely be a few breaking API
changes, see the main L<FU> module for details.
=head1 SYNOPSIS
use FU::Util qw/json_format/;

View file

@ -1,7 +1,7 @@
package FU::Validate 0.1;
use v5.36;
use experimental 'builtin';
use experimental 'builtin', 'for_list';
use builtin qw/true false blessed/;
use Carp 'confess';
use FU::Util 'to_bool';
@ -366,6 +366,11 @@ __END__
FU::Validate - Data and form validation and normalization
=head1 EXPERIMENTAL
This module is still in development and there will likely be a few breaking API
changes, see the main L<FU> module for details.
=head1 DESCRIPTION
This module provides an easy and simple interface for data validation. It can

View file

@ -83,6 +83,11 @@ __END__
FU::XMLWriter - Convenient and efficient XML and HTML generator.
=head1 EXPERIMENTAL
This module is still in development and there will likely be a few breaking API
changes, see the main L<FU> module for details.
=head1 SYNOPSIS
use FU::XMLWriter ':html5';

View file

@ -8,12 +8,16 @@ os_unsupported if $Config{usequadmath};
WriteMakefile(
NAME => 'FU',
VERSION_FROM => 'FU.pm',
ABSTRACT_FROM => 'FU.pm',
LICENSE => 'mit',
AUTHOR => 'Yorhel <projects@yorhel.nl>',
NO_MYMETA => 1,
MIN_PERL_VERSION => 'v5.36',
META_MERGE => {
dynamic_config => 0,
resources => {
repository => 'https://code.blicky.net/yorhel/fu',
},
},
OPTIMIZE => '-g -O2 -Wall -Wextra',
depend => { '$(OBJECT)', 'c/*.c' },
);

View file

@ -1,9 +1,14 @@
# FU - Framework Ultimatum
# FU - Framework Ultimatum: A Lean and Efficient Zero-Dependency Web Framework
WIP.
FU is a web development framework for Perl and a collection of handy utility
modules.
*Contributing:* Refer to my [contribution guidelines](https://dev.yorhel.nl/contributing).
## Project Status
**EXPERIMENTAL**; expect breaking changes.
## Build & Install
```sh
@ -18,7 +23,6 @@ Things that may or may not happen:
- FU::JSON - JSON::{XS,PP,etc}-compatible wrapper around FU::Util's JSON functions? I prolly won't need this myself, but could be handy.
- FU::DBI - DBI wrapper with a FU::Pg-like API, for easier integration into FU.
- FU::Validate - TUWF::Validate & normalization with some improvements.
- FU::Mailer - Simple sendmail wrapper
# License

View file

@ -180,7 +180,7 @@ static double fu_timediff(const struct timespec *a, const struct timespec *b) {
/* -1 if arg is not a bool, 0 on false, 1 on true */
static int fu_2bool(SV *val) {
static int fu_2bool(pTHX_ SV *val) {
if (SvIsBOOL(val)) return BOOL_INTERNALS_sv_isbool_true(val) ? 1 : 0;
if (!SvROK(val)) return -1;
SV *rv = SvRV(val);

View file

@ -231,7 +231,7 @@ static void fujson_fmt_obj(pTHX_ fujson_fmt_ctx *ctx, SV *rv, SV *obj) {
static void fujson_fmt(pTHX_ fujson_fmt_ctx *ctx, SV *val) {
SvGETMAGIC(val);
int r = fu_2bool(val);
int r = fu_2bool(aTHX_ val);
if (r != -1) { /* Must check SvISBOOL() before IOKp & POKp, because it implies both flags */
if (r) fustr_write(ctx->out, "true", 4);
else fustr_write(ctx->out, "false", 5);

View file

@ -77,7 +77,7 @@ RECVFN(bool) {
}
SENDFN(bool) {
int r = fu_2bool(val); /* So that we also recognize \0 and \1 */
int r = fu_2bool(aTHX_ val); /* So that we also recognize \0 and \1 */
fustr_write_ch(out, r < 0 ? SvTRUE(val) : r);
}

View file

@ -1,4 +1,4 @@
use v5.38;
use v5.36;
use Test::More;
use FU::Util 'httpdate_format', 'httpdate_parse';