diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..a571959 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,2 @@ +0.1 - 2025-02-25 + - Initial release diff --git a/FU.pm b/FU.pm index 2185dce..4601423 100644 --- a/FU.pm +++ b/FU.pm @@ -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; diff --git a/FU.xs b/FU.xs index 9098629..4d809c7 100644 --- a/FU.xs +++ b/FU.xs @@ -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: diff --git a/FU/Log.pm b/FU/Log.pm index f93b8d6..f22c1c3 100644 --- a/FU/Log.pm +++ b/FU/Log.pm @@ -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 module for details. + =head1 SYNOPSIS use FU::Log 'log_write'; diff --git a/FU/Pg.pm b/FU/Pg.pm index 9db55a4..284cb72 100644 --- a/FU/Pg.pm +++ b/FU/Pg.pm @@ -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 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 Custom per-type configuration. =head2 Errors -I +All methods can throw an exception on error. When possible, the error message +is constructed using L's C, including a full stack trace. + +SQL errors and other errors from I are reported with a C +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. + +=back + =head1 LIMITATIONS diff --git a/FU/SQL.pm b/FU/SQL.pm index c3ff97f..e528b59 100644 --- a/FU/SQL.pm +++ b/FU/SQL.pm @@ -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 module for details. + =head1 SYNOPSIS use FU::SQL; diff --git a/FU/Util.pm b/FU/Util.pm index c610cd2..b36ab37 100644 --- a/FU/Util.pm +++ b/FU/Util.pm @@ -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. +=head1 EXPERIMENTAL + +This module is still in development and there will likely be a few breaking API +changes, see the main L module for details. + =head1 SYNOPSIS use FU::Util qw/json_format/; diff --git a/FU/Validate.pm b/FU/Validate.pm index 7146e92..69ea829 100644 --- a/FU/Validate.pm +++ b/FU/Validate.pm @@ -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 module for details. + =head1 DESCRIPTION This module provides an easy and simple interface for data validation. It can diff --git a/FU/XMLWriter.pm b/FU/XMLWriter.pm index 9c6fd64..5678d6c 100644 --- a/FU/XMLWriter.pm +++ b/FU/XMLWriter.pm @@ -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 module for details. + =head1 SYNOPSIS use FU::XMLWriter ':html5'; diff --git a/Makefile.PL b/Makefile.PL index 86cce2c..2da15d4 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -8,12 +8,16 @@ os_unsupported if $Config{usequadmath}; WriteMakefile( NAME => 'FU', VERSION_FROM => 'FU.pm', + ABSTRACT_FROM => 'FU.pm', LICENSE => 'mit', + AUTHOR => 'Yorhel ', 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' }, ); diff --git a/README.md b/README.md index 4cabcec..9cf7cb8 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/c/common.c b/c/common.c index 106ec5b..849d9e8 100644 --- a/c/common.c +++ b/c/common.c @@ -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); diff --git a/c/jsonfmt.c b/c/jsonfmt.c index d1e145d..e6aab96 100644 --- a/c/jsonfmt.c +++ b/c/jsonfmt.c @@ -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); diff --git a/c/pgtypes.c b/c/pgtypes.c index 406bb59..c51226b 100644 --- a/c/pgtypes.c +++ b/c/pgtypes.c @@ -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); } diff --git a/t/httpdate.t b/t/httpdate.t index 0b4f863..07fb05a 100644 --- a/t/httpdate.t +++ b/t/httpdate.t @@ -1,4 +1,4 @@ -use v5.38; +use v5.36; use Test::More; use FU::Util 'httpdate_format', 'httpdate_parse';