diff --git a/CMakeLists.txt b/CMakeLists.txt index dbee8cf..d790090 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.10) -project(fun VERSION 0.40.3 LANGUAGES C) +project(fun VERSION 0.40.4 LANGUAGES C) set(CMAKE_C_STANDARD 99) set(CMAKE_C_STANDARD_REQUIRED ON) diff --git a/cmake/Extensions/Extensions.cmake b/cmake/Extensions/Extensions.cmake index 98c3805..ccb4fa9 100644 --- a/cmake/Extensions/Extensions.cmake +++ b/cmake/Extensions/Extensions.cmake @@ -17,7 +17,6 @@ include(${CMAKE_SOURCE_DIR}/cmake/Extensions/PCSC.cmake) include(${CMAKE_SOURCE_DIR}/cmake/Extensions/JSON.cmake) include(${CMAKE_SOURCE_DIR}/cmake/Extensions/INI.cmake) include(${CMAKE_SOURCE_DIR}/cmake/Extensions/XML2.cmake) -include(${CMAKE_SOURCE_DIR}/cmake/Extensions/LIBSQL.cmake) include(${CMAKE_SOURCE_DIR}/cmake/Extensions/PCRE2.cmake) include(${CMAKE_SOURCE_DIR}/cmake/Extensions/CURL.cmake) include(${CMAKE_SOURCE_DIR}/cmake/Extensions/REPL.cmake) @@ -31,7 +30,7 @@ _fun_print_feature("PCSC (FUN_WITH_PCSC)" FUN_WITH_PCSC) _fun_print_feature("JSON-C (FUN_WITH_JSON)" FUN_WITH_JSON) _fun_print_feature("INI/iniparser (FUN_WITH_INI)" FUN_WITH_INI) _fun_print_feature("libxml2 (FUN_WITH_XML2)" FUN_WITH_XML2) -_fun_print_feature("libsql (FUN_WITH_LIBSQL)" FUN_WITH_LIBSQL) +## libsql extension removed _fun_print_feature("PCRE2 (FUN_WITH_PCRE2)" FUN_WITH_PCRE2) _fun_print_feature("libcurl (FUN_WITH_CURL)" FUN_WITH_CURL) _fun_print_feature("REPL (FUN_WITH_REPL)" FUN_WITH_REPL) diff --git a/docs/README.md b/docs/README.md index 1d8e140..fbf067a 100644 --- a/docs/README.md +++ b/docs/README.md @@ -47,7 +47,7 @@ This file serves as an index of the documents in this directory. Links are relat Documentation for optional, build-time selectable integrations lives in [external/](./external/): - [Index of extensions](./external/README.md) - - Highlights: [cURL](./external/curl.md), [INI](./external/ini.md), [JSON](./external/json.md), [XML (libxml2)](./external/xml2.md), [SQLite](./external/sqlite.md), [libSQL](./external/libsql.md), [PCRE2](./external/pcre2.md), [PC/SC](./external/pcsc.md), [Notcurses](./external/notcurses.md), [Tcl/Tk](./external/tcltk.md), [OpenSSL](./external/openssl.md) + - Highlights: [cURL](./external/curl.md), [INI](./external/ini.md), [JSON](./external/json.md), [XML (libxml2)](./external/xml2.md), [SQLite](./external/sqlite.md), [PCRE2](./external/pcre2.md), [PC/SC](./external/pcsc.md), [Tcl/Tk](./external/tcltk.md), [OpenSSL](./external/openssl.md) ## Tips diff --git a/docs/external/README.md b/docs/external/README.md index 5219cbd..d417a38 100644 --- a/docs/external/README.md +++ b/docs/external/README.md @@ -13,13 +13,10 @@ This section documents Fun's optional, build-time selectable extensions. Each pa - [JSON (json-c)](./json.md) - [libxml2 (XML)](./xml2.md) - [SQLite](./sqlite.md) -- [libSQL (SQLite-compatible)](./libsql.md) - [PCRE2 (Perl-compatible regex)](./pcre2.md) - [PC/SC (Smart cards)](./pcsc.md) -- [Notcurses (TUI)](./notcurses.md) - [Tcl/Tk (GUI)](./tcltk.md) - [OpenSSL](./openssl.md) -- [LibreSSL](./libressl.md) ## Notes: diff --git a/docs/external/libressl.md b/docs/external/libressl.md deleted file mode 100644 index fe38c79..0000000 --- a/docs/external/libressl.md +++ /dev/null @@ -1 +0,0 @@ -This page has been removed. LibreSSL integration was dropped from the Fun project, along with related examples and build options. diff --git a/docs/external/libsql.md b/docs/external/libsql.md deleted file mode 100644 index 43662a7..0000000 --- a/docs/external/libsql.md +++ /dev/null @@ -1,17 +0,0 @@ -# libSQL extension (optional) - -- CMake option: FUN_WITH_LIBSQL=ON -- Purpose: SQLite-compatible client using the libSQL (Turso) library. -- Homepage: https://libsql.org/ - -## Opcodes: - -- OP_LIBSQL_OPEN: pops url_or_path; pushes handle (>0) or 0 -- OP_LIBSQL_CLOSE: pops handle; pushes Nil -- OP_LIBSQL_EXEC: pops sql, handle; pushes rc:int (0=OK) -- OP_LIBSQL_QUERY: pops sql, handle; pushes array - -## Notes: - -- Uses a SQLite-compatible C API provided by libSQL; behavior is similar to the SQLite backend. -- This module is independent from the SQLite extension; you may enable either or both. diff --git a/docs/external/notcurses.md b/docs/external/notcurses.md deleted file mode 100644 index f845843..0000000 --- a/docs/external/notcurses.md +++ /dev/null @@ -1,27 +0,0 @@ -# Notcurses (TUI) extension (optional) - -- CMake option: FUN_WITH_NOTCURSES=ON -- Purpose: Terminal UI capabilities via the Notcurses library. -- Homepage: https://notcurses.com/ - -## Opcodes: - -- OP_NC_INIT: initialize Notcurses; returns 1 on success, 0 on failure -- OP_NC_SHUTDOWN: shutdown; returns 0 -- OP_NC_CLEAR: clear screen/plane; returns 0 -- OP_NC_DRAW_TEXT: pops text, x, y; draws; returns 0 -- OP_NC_GETCH: pops timeout_ms; returns codepoint or -1 on timeout/error -- OP_NC_GET_SIZE: push [rows, cols] of the stdplane, or -1 if unavailable -- OP_NC_SET_STYLE: pops style, bg_rgb, fg_rgb; sets colors/styles for stdplane; returns 0/-1 -- OP_NC_DRAW_CHAR: pops ch, x, y; draws a single Unicode codepoint; returns 0/-1 -- OP_NC_DRAW_HLINE: pops len, x, y, ch; draws a horizontal line; returns 0/-1 -- OP_NC_DRAW_VLINE: pops len, x, y, ch; draws a vertical line; returns 0/-1 -- OP_NC_BOX: pops x, y, w, h, style; draws a rectangle using ASCII/Unicode box glyphs; returns 0/-1 -- OP_NC_FILL: pops x, y, w, h, ch; fills an area with a codepoint; returns 0/-1 -- OP_NC_RENDER: forces a render; returns 0/-1 - -## Notes: - -- Requires Notcurses development headers/libs. -- Behavior may vary across terminals; see the implementation for details. -- When Fun is built without Notcurses (FUN_WITH_NOTCURSES=OFF), these opcodes still exist but perform no-ops and return -1/0 as documented, allowing scripts to degrade gracefully. diff --git a/docs/opcodes.md b/docs/opcodes.md index 3d512e9..5b04a27 100644 --- a/docs/opcodes.md +++ b/docs/opcodes.md @@ -157,12 +157,7 @@ This document provides an overview of the available VM opcodes implemented under - OP_SQLITE_EXEC: Execute statement; pops handle:int, sql:string; pushes rc:int (0=OK). - OP_SQLITE_QUERY: Run query; pops handle:int, sql:string; pushes array>. -## libSQL - -- OP_LIBSQL_OPEN: Open database (url or path); pops string; pushes handle (>0) or 0. -- OP_LIBSQL_CLOSE: Close database; pops handle; pushes Nil. -- OP_LIBSQL_EXEC: Execute statement; pops handle:int, sql:string; pushes rc:int (0=OK). -- OP_LIBSQL_QUERY: Run query; pops handle:int, sql:string; pushes array>. + ## OS, Time, Processes, Threads, Sockets, Serial @@ -245,9 +240,7 @@ This document provides an overview of the available VM opcodes implemented under - OP_NC_FILL: Fill rectangle with codepoint; pops x:int, y:int, w:int, h:int, ch:int; pushes 0/-1. - OP_NC_RENDER: Force a render; pushes 0/-1. -## SQLite-compatible lib (libSQL) - -- See “libSQL” section above; identical opcode set with different backend. + ## TK (Tcl/Tk UI) diff --git a/examples/external/libsql/libsql_example.fun b/examples/external/libsql/libsql_example.fun deleted file mode 100755 index 1bfc430..0000000 --- a/examples/external/libsql/libsql_example.fun +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env fun - -/* - * This file is part of the Fun programming language. - * https://fun-lang.xyz/ - * - * Copyright 2025 Johannes Findeisen - * Licensed under the terms of the Apache-2.0 license. - * https://opensource.org/license/apache-2-0 - * - * Added: 2025-11-26 - */ - -// Demonstrates the optional libSQL extension -// Build with: cmake -S . -B build -DFUN_WITH_LIBSQL=ON && cmake --build build - -// Prepare sample DB from SQL if needed (requires sqlite3 CLI installed) -// Create it once with: -// sqlite3 ./database.sqlite < ./examples/data/database.sql - -number h = libsql_open("./database.sqlite") -if h == 0 - print("Failed to open libSQL database") -else - libsql_exec(h, "CREATE TABLE IF NOT EXISTS todos(id INTEGER PRIMARY KEY, title TEXT, done INT)") - libsql_exec(h, "DELETE FROM todos") - libsql_exec(h, "INSERT INTO todos(title, done) VALUES('Buy milk', 0)") - libsql_exec(h, "INSERT INTO todos(title, done) VALUES('Write code', 1)") - - rows = libsql_query(h, "SELECT id, title, done FROM todos ORDER BY id") - for row in rows - print(to_string(row["id"]) + ": " + to_string(row["title"]) + " (done="+to_string(row["done"]) + ")") - - rows = libsql_query(h, "SELECT id, title, done, created_at FROM tasks ORDER BY id;") - print("Tasks (" + to_string(len(rows)) + "):") - for row in rows - string status = "✘" - if row["done"] == 1 - status = "✔" - print("- [" + status + "] (#" + to_string(row["id"]) + ") " + to_string(row["title"]) + " — " + to_string(row["created_at"])) - - number rc = libsql_exec(h, "INSERT INTO tasks (title, done) VALUES ('Try Fun + SQLite', 0);") - print("Insert rc=" + to_string(rc)) - - rows2 = libsql_query(h, "SELECT count(*) AS cnt FROM tasks;") - print("Total tasks now: " + to_string(rows2[0]["cnt"])) - - libsql_close(h) - -/* Example output: -1: Buy milk (done=0) -2: Write code (done=1) -Tasks (3): -- [✔] (#1) Write Fun + SQLite example — 2025-11-26 23:20:41 -- [✘] (#2) Ship optional feature flag — 2025-11-26 23:20:41 -- [✘] (#3) Celebrate with coffee — 2025-11-26 23:20:41 -Insert rc=0 -Total tasks now: 4 -*/ diff --git a/src/bytecode.c b/src/bytecode.c index e3ed017..dfbd7b5 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -257,14 +257,6 @@ static const char *opcode_name(OpCode op) { return "SQLITE_EXEC"; case OP_SQLITE_QUERY: return "SQLITE_QUERY"; - case OP_LIBSQL_OPEN: - return "LIBSQL_OPEN"; - case OP_LIBSQL_CLOSE: - return "LIBSQL_CLOSE"; - case OP_LIBSQL_EXEC: - return "LIBSQL_EXEC"; - case OP_LIBSQL_QUERY: - return "LIBSQL_QUERY"; case OP_PCSC_ESTABLISH: return "PCSC_ESTABLISH"; case OP_PCSC_RELEASE: diff --git a/src/bytecode.h b/src/bytecode.h index 64349d2..0171a22 100644 --- a/src/bytecode.h +++ b/src/bytecode.h @@ -162,11 +162,6 @@ typedef enum { OP_SQLITE_EXEC, // pops sql, handle; pushes sqlite rc (0=OK) OP_SQLITE_QUERY, // pops sql, handle; pushes array - // libsql (optional, independent) - OP_LIBSQL_OPEN, // pops url/path; pushes handle (>0) or 0 - OP_LIBSQL_CLOSE, // pops handle; pushes Nil - OP_LIBSQL_EXEC, // pops sql, handle; pushes rc (0=OK) - OP_LIBSQL_QUERY, // pops sql, handle; pushes array // PCSC (smart card) opcodes OP_PCSC_ESTABLISH, // returns context id (>0) or 0 diff --git a/src/parser.c b/src/parser.c index 85b1fbe..af40c75 100644 --- a/src/parser.c +++ b/src/parser.c @@ -2093,91 +2093,6 @@ static int emit_primary(Bytecode *bc, const char *src, size_t len, size_t *pos) free(name); return 1; } - /* libsql builtins (independent extension) */ - if (strcmp(name, "libsql_open") == 0) { - (*pos)++; /* '(' */ - if (!emit_expression(bc, src, len, pos)) { - parser_fail(*pos, "libsql_open expects (url_or_path)"); - free(name); - return 0; - } - if (!consume_char(src, len, pos, ')')) { - parser_fail(*pos, "Expected ')' after libsql_open arg"); - free(name); - return 0; - } - bytecode_add_instruction(bc, OP_LIBSQL_OPEN, 0); - free(name); - return 1; - } - if (strcmp(name, "libsql_close") == 0) { - (*pos)++; /* '(' */ - if (!emit_expression(bc, src, len, pos)) { - parser_fail(*pos, "libsql_close expects (handle)"); - free(name); - return 0; - } - if (!consume_char(src, len, pos, ')')) { - parser_fail(*pos, "Expected ')' after libsql_close arg"); - free(name); - return 0; - } - bytecode_add_instruction(bc, OP_LIBSQL_CLOSE, 0); - free(name); - return 1; - } - if (strcmp(name, "libsql_exec") == 0) { - (*pos)++; /* '(' */ - if (!emit_expression(bc, src, len, pos)) { - parser_fail(*pos, "libsql_exec expects (handle, sql)"); - free(name); - return 0; - } - if (!consume_char(src, len, pos, ',')) { - parser_fail(*pos, "libsql_exec expects (handle, sql)"); - free(name); - return 0; - } - if (!emit_expression(bc, src, len, pos)) { - parser_fail(*pos, "libsql_exec expects (handle, sql)"); - free(name); - return 0; - } - if (!consume_char(src, len, pos, ')')) { - parser_fail(*pos, "Expected ')' after libsql_exec args"); - free(name); - return 0; - } - bytecode_add_instruction(bc, OP_LIBSQL_EXEC, 0); - free(name); - return 1; - } - if (strcmp(name, "libsql_query") == 0) { - (*pos)++; /* '(' */ - if (!emit_expression(bc, src, len, pos)) { - parser_fail(*pos, "libsql_query expects (handle, sql)"); - free(name); - return 0; - } - if (!consume_char(src, len, pos, ',')) { - parser_fail(*pos, "libsql_query expects (handle, sql)"); - free(name); - return 0; - } - if (!emit_expression(bc, src, len, pos)) { - parser_fail(*pos, "libsql_query expects (handle, sql)"); - free(name); - return 0; - } - if (!consume_char(src, len, pos, ')')) { - parser_fail(*pos, "Expected ')' after libsql_query args"); - free(name); - return 0; - } - bytecode_add_instruction(bc, OP_LIBSQL_QUERY, 0); - free(name); - return 1; - } if (strcmp(name, "curl_post") == 0) { (*pos)++; /* '(' */ if (!emit_expression(bc, src, len, pos)) { diff --git a/src/vm.c b/src/vm.c index 5b31213..fa27790 100644 --- a/src/vm.c +++ b/src/vm.c @@ -65,7 +65,6 @@ /* Note: INI opcode handlers are included below; changes in vm/ini/ .c files * require vm.c to rebuild. */ #include "external/json.c" -#include "external/libsql.c" #include "external/openssl.c" #include "external/pcre2.c" #include "external/pcsc.c" @@ -884,13 +883,7 @@ void vm_run(VM *vm, Bytecode *entry) { } #endif -/* libsql ops (independent) */ -#ifdef FUN_WITH_LIBSQL -#include "vm/libsql/close.c" -#include "vm/libsql/exec.c" -#include "vm/libsql/open.c" -#include "vm/libsql/query.c" -#endif +/* libsql support removed */ /* PCRE2 ops */ #ifdef FUN_WITH_PCRE2