Renamed ./src/external to ./src/extensions. No code logic changes. (0.40.5)
This commit is contained in:
parent
529acb77b1
commit
bb704a3778
25 changed files with 81 additions and 414 deletions
18
README.md
18
README.md
|
|
@ -89,14 +89,14 @@ See [./lib/](https://git.xw3.org/fun/fun/src/branch/main/lib) for what the stand
|
|||
### Optional extensions (build-time selectable / only testing this on Linux actually):
|
||||
|
||||
- [CGI](https://en.wikipedia.org/wiki/Common_Gateway_Interface) support builtin using [kcgi](https://kristaps.bsd.lv/kcgi/) (optional) ☐
|
||||
- [cURL (libcurl)](./docs/external/curl.md) (optional) ☑
|
||||
- [INI (iniparser)](./docs/external/ini.md) (optional) ☑
|
||||
- [JSON (json-c)](./docs/external/json.md) (optional) ☑
|
||||
- [PCRE2](./docs/external/pcre2.md) (optional) ☑
|
||||
- [PCSC (smart cards)](./docs/external/pcsc.md) (optional) ☑
|
||||
- [OpenSSL](./docs/external/openssl.md) (optional) ☑
|
||||
- [SQLite](./docs/external/sqlite.md) (optional) ☑
|
||||
- [XML (libxml2)](./docs/external/xml2.md) (optional) ☑
|
||||
- [cURL (libcurl)](./docs/extensions/curl.md) (optional) ☑
|
||||
- [INI (iniparser)](./docs/extensions/ini.md) (optional) ☑
|
||||
- [JSON (json-c)](./docs/extensions/json.md) (optional) ☑
|
||||
- [PCRE2](./docs/extensions/pcre2.md) (optional) ☑
|
||||
- [PCSC (smart cards)](./docs/extensions/pcsc.md) (optional) ☑
|
||||
- [OpenSSL](./docs/extensions/openssl.md) (optional) ☑
|
||||
- [SQLite](./docs/extensions/sqlite.md) (optional) ☑
|
||||
- [XML (libxml2)](./docs/extensions/xml2.md) (optional) ☑
|
||||
|
||||
☑ = Done / ☐ = Planned or in progress.
|
||||
|
||||
|
|
@ -106,7 +106,7 @@ There are some libs written in Fun available in the [./lib/](https://git.xw3.org
|
|||
|
||||
### OpenSSL quickstart (MD5)
|
||||
|
||||
See the dedicated page: ./docs/external/openssl.md
|
||||
See the dedicated page: ./docs/extensions/openssl.md
|
||||
|
||||
## Documentation
|
||||
|
||||
|
|
|
|||
|
|
@ -307,21 +307,21 @@ using: 1
|
|||
(optional): 11
|
||||
☐: 2
|
||||
[curl: 1
|
||||
(libcurl)](./docs/external/curl.md): 1
|
||||
(libcurl)](./docs/extensions/curl.md): 1
|
||||
☑: 11
|
||||
[ini: 1
|
||||
(iniparser)](./docs/external/ini.md): 1
|
||||
(iniparser)](./docs/extensions/ini.md): 1
|
||||
[json: 1
|
||||
(json-c)](./docs/external/json.md): 1
|
||||
[libsql](./docs/external/libsql.md): 1
|
||||
[pcre2](./docs/external/pcre2.md): 1
|
||||
(json-c)](./docs/extensions/json.md): 1
|
||||
[libsql](./docs/extensions/libsql.md): 1
|
||||
[pcre2](./docs/extensions/pcre2.md): 1
|
||||
[pcsc: 1
|
||||
(smart: 1
|
||||
cards)](./docs/external/pcsc.md): 1
|
||||
[openssl](./docs/external/openssl.md): 1
|
||||
[sqlite](./docs/external/sqlite.md): 1
|
||||
cards)](./docs/extensions/pcsc.md): 1
|
||||
[openssl](./docs/extensions/openssl.md): 1
|
||||
[sqlite](./docs/extensions/sqlite.md): 1
|
||||
[xml: 1
|
||||
(libxml2)](./docs/external/xml2.md): 1
|
||||
(libxml2)](./docs/extensions/xml2.md): 1
|
||||
=: 2
|
||||
done: 1
|
||||
planned: 1
|
||||
|
|
@ -351,7 +351,7 @@ quickstart: 1
|
|||
(md5): 1
|
||||
dedicated: 1
|
||||
page:: 1
|
||||
./docs/external/openssl.md: 1
|
||||
./docs/extensions/openssl.md: 1
|
||||
documentation: 2
|
||||
looking: 1
|
||||
docs?: 1
|
||||
|
|
|
|||
196
src/external/libressl.c
vendored
196
src/external/libressl.c
vendored
|
|
@ -1,196 +0,0 @@
|
|||
/*
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2026 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*
|
||||
* Added: 2026-02-19
|
||||
*/
|
||||
|
||||
/*
|
||||
* LibreSSL integration helpers (MD5, RIPEMD-160, SHA-256, SHA-512)
|
||||
*/
|
||||
|
||||
#ifdef FUN_WITH_LIBRESSL
|
||||
/*
|
||||
* When building with LibreSSL, include the LibreSSL-provided headers explicitly.
|
||||
* Downstream distros often ship them under /usr/include/libressl/openssl/…
|
||||
* and expect the include path to point at /usr/include/libressl so that any
|
||||
* nested `#include <openssl/...>` inside these headers resolves to the
|
||||
* corresponding LibreSSL headers as well (not the system OpenSSL 3.x ones).
|
||||
*/
|
||||
#include <libressl/openssl/evp.h>
|
||||
/* Compatibility: Prefer EVP_MD_get_size universally. If LibreSSL headers
|
||||
* don't declare it, provide a forward declaration so we can link against
|
||||
* OpenSSL's libcrypto symbol when that is what CMake found. */
|
||||
#ifndef EVP_MD_get_size
|
||||
int EVP_MD_get_size(const EVP_MD *md);
|
||||
#endif
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Compute MD5 hex of input buffer; returns malloc'ed C string (lowercase hex). */
|
||||
static char *fun_libressl_md5_hex(const unsigned char *data, size_t len) {
|
||||
static const char hexdig[] = "0123456789abcdef";
|
||||
if (!data && len != 0) return NULL;
|
||||
#ifdef FUN_WITH_LIBRESSL
|
||||
const EVP_MD *md = EVP_md5();
|
||||
if (!md) return NULL;
|
||||
int dlen = EVP_MD_get_size(md);
|
||||
if (dlen <= 0) return NULL;
|
||||
unsigned char *digest = (unsigned char *)malloc((size_t)dlen);
|
||||
if (!digest) return NULL;
|
||||
unsigned int out_len = 0;
|
||||
int ok;
|
||||
if (len == 0) {
|
||||
ok = EVP_Digest(NULL, 0, digest, &out_len, md, NULL);
|
||||
} else {
|
||||
ok = EVP_Digest(data, len, digest, &out_len, md, NULL);
|
||||
}
|
||||
if (ok != 1 || (int)out_len != dlen) {
|
||||
free(digest);
|
||||
return NULL;
|
||||
}
|
||||
char *hex = (char *)malloc((size_t)dlen * 2 + 1);
|
||||
if (!hex) {
|
||||
free(digest);
|
||||
return NULL;
|
||||
}
|
||||
for (int i = 0; i < dlen; ++i) {
|
||||
hex[2 * i] = hexdig[(digest[i] >> 4) & 0xF];
|
||||
hex[2 * i + 1] = hexdig[digest[i] & 0xF];
|
||||
}
|
||||
hex[dlen * 2] = '\0';
|
||||
free(digest);
|
||||
return hex;
|
||||
#else
|
||||
char *hex = (char *)malloc(1);
|
||||
if (hex) hex[0] = '\0';
|
||||
return hex;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Compute SHA-256 hex of input buffer; returns malloc'ed C string (lowercase hex). */
|
||||
static char *fun_libressl_sha256_hex(const unsigned char *data, size_t len) {
|
||||
static const char hexdig[] = "0123456789abcdef";
|
||||
if (!data && len != 0) return NULL;
|
||||
#ifdef FUN_WITH_LIBRESSL
|
||||
const EVP_MD *md = EVP_sha256();
|
||||
if (!md) return NULL;
|
||||
int dlen = EVP_MD_get_size(md);
|
||||
if (dlen <= 0) return NULL;
|
||||
unsigned char *digest = (unsigned char *)malloc((size_t)dlen);
|
||||
if (!digest) return NULL;
|
||||
unsigned int out_len = 0;
|
||||
int ok;
|
||||
if (len == 0) {
|
||||
ok = EVP_Digest(NULL, 0, digest, &out_len, md, NULL);
|
||||
} else {
|
||||
ok = EVP_Digest(data, len, digest, &out_len, md, NULL);
|
||||
}
|
||||
if (ok != 1 || (int)out_len != dlen) {
|
||||
free(digest);
|
||||
return NULL;
|
||||
}
|
||||
char *hex = (char *)malloc((size_t)dlen * 2 + 1);
|
||||
if (!hex) {
|
||||
free(digest);
|
||||
return NULL;
|
||||
}
|
||||
for (int i = 0; i < dlen; ++i) {
|
||||
hex[2 * i] = hexdig[(digest[i] >> 4) & 0xF];
|
||||
hex[2 * i + 1] = hexdig[digest[i] & 0xF];
|
||||
}
|
||||
hex[dlen * 2] = '\0';
|
||||
free(digest);
|
||||
return hex;
|
||||
#else
|
||||
char *hex = (char *)malloc(1);
|
||||
if (hex) hex[0] = '\0';
|
||||
return hex;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Compute SHA-512 hex of input buffer; returns malloc'ed C string (lowercase hex). */
|
||||
static char *fun_libressl_sha512_hex(const unsigned char *data, size_t len) {
|
||||
static const char hexdig[] = "0123456789abcdef";
|
||||
if (!data && len != 0) return NULL;
|
||||
#ifdef FUN_WITH_LIBRESSL
|
||||
const EVP_MD *md = EVP_sha512();
|
||||
if (!md) return NULL;
|
||||
int dlen = EVP_MD_get_size(md);
|
||||
if (dlen <= 0) return NULL;
|
||||
unsigned char *digest = (unsigned char *)malloc((size_t)dlen);
|
||||
if (!digest) return NULL;
|
||||
unsigned int out_len = 0;
|
||||
int ok;
|
||||
if (len == 0) {
|
||||
ok = EVP_Digest(NULL, 0, digest, &out_len, md, NULL);
|
||||
} else {
|
||||
ok = EVP_Digest(data, len, digest, &out_len, md, NULL);
|
||||
}
|
||||
if (ok != 1 || (int)out_len != dlen) {
|
||||
free(digest);
|
||||
return NULL;
|
||||
}
|
||||
char *hex = (char *)malloc((size_t)dlen * 2 + 1);
|
||||
if (!hex) {
|
||||
free(digest);
|
||||
return NULL;
|
||||
}
|
||||
for (int i = 0; i < dlen; ++i) {
|
||||
hex[2 * i] = hexdig[(digest[i] >> 4) & 0xF];
|
||||
hex[2 * i + 1] = hexdig[digest[i] & 0xF];
|
||||
}
|
||||
hex[dlen * 2] = '\0';
|
||||
free(digest);
|
||||
return hex;
|
||||
#else
|
||||
char *hex = (char *)malloc(1);
|
||||
if (hex) hex[0] = '\0';
|
||||
return hex;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Compute RIPEMD-160 hex of input buffer; returns malloc'ed C string (lowercase hex). */
|
||||
static char *fun_libressl_ripemd160_hex(const unsigned char *data, size_t len) {
|
||||
static const char hexdig[] = "0123456789abcdef";
|
||||
if (!data && len != 0) return NULL;
|
||||
#ifdef FUN_WITH_LIBRESSL
|
||||
const EVP_MD *md = EVP_ripemd160();
|
||||
if (!md) return NULL;
|
||||
int dlen = EVP_MD_get_size(md);
|
||||
if (dlen <= 0) return NULL;
|
||||
unsigned char *digest = (unsigned char *)malloc((size_t)dlen);
|
||||
if (!digest) return NULL;
|
||||
unsigned int out_len = 0;
|
||||
int ok;
|
||||
if (len == 0) {
|
||||
ok = EVP_Digest(NULL, 0, digest, &out_len, md, NULL);
|
||||
} else {
|
||||
ok = EVP_Digest(data, len, digest, &out_len, md, NULL);
|
||||
}
|
||||
if (ok != 1 || (int)out_len != dlen) {
|
||||
free(digest);
|
||||
return NULL;
|
||||
}
|
||||
char *hex = (char *)malloc((size_t)dlen * 2 + 1);
|
||||
if (!hex) {
|
||||
free(digest);
|
||||
return NULL;
|
||||
}
|
||||
for (int i = 0; i < dlen; ++i) {
|
||||
hex[2 * i] = hexdig[(digest[i] >> 4) & 0xF];
|
||||
hex[2 * i + 1] = hexdig[digest[i] & 0xF];
|
||||
}
|
||||
hex[dlen * 2] = '\0';
|
||||
free(digest);
|
||||
return hex;
|
||||
#else
|
||||
char *hex = (char *)malloc(1);
|
||||
if (hex) hex[0] = '\0';
|
||||
return hex;
|
||||
#endif
|
||||
}
|
||||
58
src/external/libsql.c
vendored
58
src/external/libsql.c
vendored
|
|
@ -1,58 +0,0 @@
|
|||
/*
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*
|
||||
* Added: 2025-11-26 (2025-12-11 migrated from src/vm/libsql/common.c)
|
||||
*/
|
||||
|
||||
#ifdef FUN_WITH_LIBSQL
|
||||
#include <sqlite3.h> /* libsql provides a sqlite3-compatible C API */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef struct LibSqlHandle {
|
||||
int id;
|
||||
sqlite3 *db;
|
||||
struct LibSqlHandle *next;
|
||||
} LibSqlHandle;
|
||||
|
||||
static LibSqlHandle *g_libsql_handles = NULL;
|
||||
static int g_libsql_next_id = 1;
|
||||
|
||||
static LibSqlHandle *libsql_reg_add(sqlite3 *db) {
|
||||
LibSqlHandle *h = (LibSqlHandle *)malloc(sizeof(LibSqlHandle));
|
||||
if (!h) return NULL;
|
||||
h->id = g_libsql_next_id++;
|
||||
h->db = db;
|
||||
h->next = g_libsql_handles;
|
||||
g_libsql_handles = h;
|
||||
return h;
|
||||
}
|
||||
|
||||
static LibSqlHandle *libsql_reg_get(int id) {
|
||||
LibSqlHandle *p = g_libsql_handles;
|
||||
while (p) {
|
||||
if (p->id == id) return p;
|
||||
p = p->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void libsql_reg_del(int id) {
|
||||
LibSqlHandle **pp = &g_libsql_handles;
|
||||
while (*pp) {
|
||||
if ((*pp)->id == id) {
|
||||
LibSqlHandle *dead = *pp;
|
||||
*pp = (*pp)->next;
|
||||
free(dead);
|
||||
return;
|
||||
}
|
||||
pp = &((*pp)->next);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
79
src/external/tcltk.c
vendored
79
src/external/tcltk.c
vendored
|
|
@ -1,79 +0,0 @@
|
|||
/*
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*
|
||||
* Added: 2025-12-11 (2025-12-11 migrated from src/vm.c)
|
||||
*/
|
||||
|
||||
#ifdef FUN_WITH_TCLTK
|
||||
#include <tcl.h>
|
||||
#include <tk.h>
|
||||
static Tcl_Interp *g_fun_tcl_interp = NULL;
|
||||
|
||||
static void fun_tk_init_once(void) {
|
||||
if (g_fun_tcl_interp) return;
|
||||
Tcl_FindExecutable(NULL);
|
||||
g_fun_tcl_interp = Tcl_CreateInterp();
|
||||
if (!g_fun_tcl_interp) return;
|
||||
if (Tcl_Init(g_fun_tcl_interp) != TCL_OK) {
|
||||
fprintf(stderr, "Tcl_Init failed: %s\n", Tcl_GetStringResult(g_fun_tcl_interp));
|
||||
}
|
||||
if (Tk_Init(g_fun_tcl_interp) != TCL_OK) {
|
||||
fprintf(stderr, "Tk_Init failed: %s\n", Tcl_GetStringResult(g_fun_tcl_interp));
|
||||
}
|
||||
/* Ensure the app terminates if the main window is closed via window manager */
|
||||
/* Best-effort: set WM_DELETE_WINDOW handler to exit the process. */
|
||||
Tcl_Eval(g_fun_tcl_interp, "wm protocol . WM_DELETE_WINDOW {exit 0}");
|
||||
}
|
||||
|
||||
static int fun_tk_eval_script(const char *script) {
|
||||
fun_tk_init_once();
|
||||
if (!g_fun_tcl_interp) return -1;
|
||||
int rc = Tcl_Eval(g_fun_tcl_interp, script ? script : "");
|
||||
return rc; /* TCL_OK = 0 */
|
||||
}
|
||||
|
||||
static const char *fun_tk_get_result(void) {
|
||||
fun_tk_init_once();
|
||||
if (!g_fun_tcl_interp) return "";
|
||||
return Tcl_GetStringResult(g_fun_tcl_interp);
|
||||
}
|
||||
|
||||
static void fun_tk_loop(void) {
|
||||
fun_tk_init_once();
|
||||
if (!g_fun_tcl_interp) return;
|
||||
/* Drive Tk event loop until all main windows are closed */
|
||||
while (Tk_GetNumMainWindows() > 0) {
|
||||
while (Tcl_DoOneEvent(0)) {
|
||||
}
|
||||
/* tiny sleep to avoid busy spin */
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
Sleep(1);
|
||||
#else
|
||||
#include <time.h>
|
||||
struct timespec ts = {0, 1000000}; /* 1 ms */
|
||||
nanosleep(&ts, NULL);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#else
|
||||
/* Stubs when Tcl/Tk is disabled */
|
||||
static void fun_tk_init_once(void) {
|
||||
(void)0;
|
||||
}
|
||||
static int fun_tk_eval_script(const char *script) {
|
||||
(void)script;
|
||||
return -1;
|
||||
}
|
||||
static const char *fun_tk_get_result(void) {
|
||||
return "";
|
||||
}
|
||||
static void fun_tk_loop(void) {
|
||||
(void)0;
|
||||
}
|
||||
#endif
|
||||
16
src/vm.c
16
src/vm.c
|
|
@ -56,20 +56,20 @@
|
|||
/* Notcurses support removed */
|
||||
|
||||
// Optional by extensions commonly used code. #ifdef's are in each single file.
|
||||
#include "external/curl.c"
|
||||
#include "external/ini.c"
|
||||
#include "extensions/curl.c"
|
||||
#include "extensions/ini.c"
|
||||
#ifdef FUN_WITH_INI
|
||||
/* Central INI handle registry and helpers */
|
||||
#include "vm/ini/handles.c"
|
||||
#endif
|
||||
/* Note: INI opcode handlers are included below; changes in vm/ini/ .c files
|
||||
* require vm.c to rebuild. */
|
||||
#include "external/json.c"
|
||||
#include "external/openssl.c"
|
||||
#include "external/pcre2.c"
|
||||
#include "external/pcsc.c"
|
||||
#include "external/sqlite.c"
|
||||
#include "external/xml2.c"
|
||||
#include "extensions/json.c"
|
||||
#include "extensions/openssl.c"
|
||||
#include "extensions/pcre2.c"
|
||||
#include "extensions/pcsc.c"
|
||||
#include "extensions/sqlite.c"
|
||||
#include "extensions/xml2.c"
|
||||
|
||||
/* forward declarations for include mapping used in error reporting */
|
||||
extern char *preprocess_includes(const char *src);
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ This file serves as an index of the documents in this directory. Links are relat
|
|||
|
||||
## Basics
|
||||
|
||||
- [./handbook/](./handbook/) - Comprehensive handbook for the Fun language and VM: install/build, configuration flags, usage, and full feature overview.
|
||||
- [./repl/](./repl/) - REPL user guide: how to build/launch, editing and history, completions, REPL-on-error, and tips.
|
||||
- [Handbook](./handbook/) - Comprehensive handbook for the Fun language and VM: install/build, configuration flags, usage, and full feature overview.
|
||||
- [REPL](./repl/) - REPL user guide: how to build/launch, editing and history, completions, REPL-on-error, and tips.
|
||||
- [Specification v0.4](https://git.xw3.org/fun/fun/src/branch/main/spec/v0.4/){:class="git"}
|
||||
- [Specification v0.3](https://git.xw3.org/fun/fun/src/branch/main/spec/v0.3/){:class="git"}
|
||||
- [Specification v0.2](https://git.xw3.org/fun/fun/src/branch/main/spec/v0.2/){:class="git"}
|
||||
|
|
@ -32,50 +32,50 @@ The examples directory contains demonstrations of most Fun features, from basic
|
|||
|
||||
## Overview
|
||||
|
||||
- [./types/](./types/) - Core types (numbers, strings, arrays, maps, nil/bool), common operations, patterns, and interop notes.
|
||||
- [./numbers/](./numbers/) - Working with integers and floats: arithmetic, conversions, clamping, bitwise ops, and patterns.
|
||||
- [./strings/](./strings/) - Working with strings: literals/escaping, concatenation, substr/find, split, and conversions.
|
||||
- [./arrays/](./arrays/) - Working with arrays: creation, indexing/slicing, iteration patterns, helpers, and idioms.
|
||||
- [./maps/](./maps/) - Working with maps: construction, lookup/update, merging, iteration, and common patterns.
|
||||
- [./includes/](./includes/) - Using local vs. system includes, FUN_LIB_DIR, DEFAULT_LIB_DIR, and namespaced includes with `as`.
|
||||
- [./opcodes/](./opcodes/) - VM opcodes overview grouped by domain with brief behavior/stack notes.
|
||||
- [./internals/](./internals/) - Implementation details: bytecode format, VM architecture, stacks/frames, parser, and dispatch.
|
||||
- [./vm/](./vm/) - VM configuration constants: maximum stack depth, local/global variable limits, and output buffer size.
|
||||
- [./rust/](./rust/) - Writing Rust-backed opcodes and wiring them into the C VM; build/setup notes.
|
||||
- [./examples/](./examples/) - How to run the examples and the interactive showcase script, with environment tips.
|
||||
- [./testing/](./testing/) - How to build and run tests/targets with CMake/CTest, and where to add new tests.
|
||||
- [./troubleshooting/](./troubleshooting/) - Common issues and quick fixes for build, includes, and REPL usage.
|
||||
- [Types](./types/) - Core types (numbers, strings, arrays, maps, nil/bool), common operations, patterns, and interop notes.
|
||||
- [Numbers](./numbers/) - Working with integers and floats: arithmetic, conversions, clamping, bitwise ops, and patterns.
|
||||
- [Strings](./strings/) - Working with strings: literals/escaping, concatenation, substr/find, split, and conversions.
|
||||
- [Arrays](./arrays/) - Working with arrays: creation, indexing/slicing, iteration patterns, helpers, and idioms.
|
||||
- [Mmaps](./maps/) - Working with maps: construction, lookup/update, merging, iteration, and common patterns.
|
||||
- [Includes](./includes/) - Using local vs. system includes, FUN_LIB_DIR, DEFAULT_LIB_DIR, and namespaced includes with `as`.
|
||||
- [Opcodes](./opcodes/) - VM opcodes overview grouped by domain with brief behavior/stack notes.
|
||||
- [Internals](./internals/) - Implementation details: bytecode format, VM architecture, stacks/frames, parser, and dispatch.
|
||||
- [VM](./vm/) - VM configuration constants: maximum stack depth, local/global variable limits, and output buffer size.
|
||||
- [Rust](./rust/) - Writing Rust-backed opcodes and wiring them into the C VM; build/setup notes.
|
||||
- [Examples](./examples/) - How to run the examples and the interactive showcase script, with environment tips.
|
||||
- [Testing](./testing/) - How to build and run tests/targets with CMake/CTest, and where to add new tests.
|
||||
- [Troubleshooting](./troubleshooting/) - Common issues and quick fixes for build, includes, and REPL usage.
|
||||
|
||||
## New and supplemental guides
|
||||
|
||||
- [./build/](./build/) - How to build Fun with CMake, available targets, and build options (FUN_DEBUG, FUN_USE_MUSL, FUN_WITH_CPP, FUN_WITH_RUST, FUN_WITH_OPENSSL).
|
||||
- [./cli/](./cli/) - Command-line usage of the `fun` executable: synopsis, options, exit codes, includes and library paths.
|
||||
- [./fun/](./fun/) - Full usage guide for the `fun` executable: invocation patterns, REPL, env vars, include paths, examples, and install locations.
|
||||
- [./asyncio/](./asyncio/) - Async I/O primitives and patterns: non-blocking sockets, fd polling, examples, and best practices.
|
||||
- [./funstx/](./funstx/) - Syntax checker for .fun files with optional --fix auto-corrections; usage, exit codes, and limitations.
|
||||
- [./contributing/](./contributing/) - How to contribute: project structure, coding style, running tests, and PR guidelines.
|
||||
- [./style-guide/](./style-guide/) - Coding conventions for C and Fun (indentation, naming, idioms).
|
||||
- [./stdlib/](./stdlib/) - Overview of the standard library modules under ./lib with one-line summaries.
|
||||
- [./embedding/](./embedding/) - Embedding the VM from C/Rust, lifecycle, and host integration tips.
|
||||
- [./errors-and-diagnostics/](./errors-and-diagnostics/) - Understanding parser/runtime errors and enabling diagnostics.
|
||||
- [./performance/](./performance/) - Build/runtime tuning tips and patterns for better performance.
|
||||
- [./security-and-sandboxing/](./security-and-sandboxing/) - Trust boundaries, I/O expectations, and capability restrictions.
|
||||
- [,/faq/](./faq/) - Frequently asked questions and quick answers.
|
||||
- [./website/](./website/) - Documentation for the [fun-lang.xyz](https://fun-lang.xyz) website in the `./web/` directory.
|
||||
- [./writing-tests/](./writing-tests/) - How to author new tests for Fun and opcode components.
|
||||
- [./bytecode-format/](./bytecode-format/) - Reference for the bytecode format (split out from internals for convenience).
|
||||
- [./roadmap/](./roadmap/) - High-level direction, planned features, and pointers to issues.
|
||||
- [Build](./build/) - How to build Fun with CMake, available targets, and build options (FUN_DEBUG, FUN_USE_MUSL, FUN_WITH_CPP, FUN_WITH_RUST, FUN_WITH_OPENSSL).
|
||||
- [CLI](./cli/) - Command-line usage of the `fun` executable: synopsis, options, exit codes, includes and library paths.
|
||||
- [fun](./fun/) - Full usage guide for the `fun` executable: invocation patterns, REPL, env vars, include paths, examples, and install locations.
|
||||
- [Asyncio](./asyncio/) - Async I/O primitives and patterns: non-blocking sockets, fd polling, examples, and best practices.
|
||||
- [Funstx](./funstx/) - Syntax checker for .fun files with optional --fix auto-corrections; usage, exit codes, and limitations.
|
||||
- [Contributing](./contributing/) - How to contribute: project structure, coding style, running tests, and PR guidelines.
|
||||
- [Style-guide](./style-guide/) - Coding conventions for C and Fun (indentation, naming, idioms).
|
||||
- [stdlib](./stdlib/) - Overview of the standard library modules under ./lib with one-line summaries.
|
||||
- [Embedding](./embedding/) - Embedding the VM from C/Rust, lifecycle, and host integration tips.
|
||||
- [Errors-and-diagnostics](./errors-and-diagnostics/) - Understanding parser/runtime errors and enabling diagnostics.
|
||||
- [Performance](./performance/) - Build/runtime tuning tips and patterns for better performance.
|
||||
- [Security-and-Sandboxing](./security-and-sandboxing/) - Trust boundaries, I/O expectations, and capability restrictions.
|
||||
- [FAQ](./faq/) - Frequently asked questions and quick answers.
|
||||
- [Website](./website/) - Documentation for the [fun-lang.xyz](https://fun-lang.xyz) website in the `./web/` directory.
|
||||
- [Writing-Tests](./writing-tests/) - How to author new tests for Fun and opcode components.
|
||||
- [Bytecode-Format](./bytecode-format/) - Reference for the bytecode format (split out from internals for convenience).
|
||||
- [Roadmap](./roadmap/) - High-level direction, planned features, and pointers to issues.
|
||||
|
||||
## Examples
|
||||
|
||||
- [./examples/](./examples/) - Catalog of all example scripts under [https://git.xw3.org/fun/fun/src/branch/main/examples](https://git.xw3.org/fun/fun/src/branch/main/examples){:class="git"}: what each area contains, how to run them, required env vars, and extension requirements.
|
||||
- [Examples](./examples/) - Catalog of all example scripts under [https://git.xw3.org/fun/fun/src/branch/main/examples](https://git.xw3.org/fun/fun/src/branch/main/examples){:class="git"}: what each area contains, how to run them, required env vars, and extension requirements.
|
||||
|
||||
## External extensions
|
||||
## Extensions
|
||||
|
||||
Documentation for optional, build-time selectable integrations lives in [external/](./external/):
|
||||
Documentation for optional, build-time selectable integrations lives in [extensions/](./extensions/):
|
||||
|
||||
- [Index of extensions](./external/)
|
||||
- Highlights: [cURL](./external/curl/), [INI](./external/ini/), [JSON](./external/json/), [XML (libxml2)](./external/xml2/), [SQLite](./external/sqlite/), [PCRE2](./external/pcre2/), [PC/SC](./external/pcsc/), [OpenSSL](./external/openssl/)
|
||||
- [Index of extensions](./extensions/)
|
||||
- Highlights: [cURL](./extensions/curl/), [INI](./extensions/ini/), [JSON](./extensions/json/), [XML (libxml2)](./extensions/xml2/), [SQLite](./extensions/sqlite/), [PCRE2](./extensions/pcre2/), [PC/SC](./extensions/pcsc/), [OpenSSL](./extensions/openssl/)
|
||||
|
||||
## Tips
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ noDate: false
|
|||
title: Fun - cURL (libcurl) extension (optional)
|
||||
subtitle: Documentation for cURL (libcurl) extension (optional)
|
||||
description: Documentation for cURL (libcurl) extension (optional)
|
||||
permalink: /documentation/external/curl/
|
||||
permalink: /documentation/extensions/curl/
|
||||
lang: en
|
||||
tags:
|
||||
- curl
|
||||
|
|
@ -4,10 +4,10 @@ published: true
|
|||
noToc: false
|
||||
noComments: false
|
||||
noDate: false
|
||||
title: Fun - External integrations (optional extensions)
|
||||
subtitle: Catalog of all example scripts under ./examples/, what each area contains, how to run them, required env vars, and extension requirements.
|
||||
description: Catalog of all example scripts under ./examples/, what each area contains, how to run them, required env vars, and extension requirements.
|
||||
permalink: /documentation/external/
|
||||
title: Fun - Optional extensions
|
||||
subtitle: Catalog of optional, build-time selectable extensions for the Fun VM (e.g., cURL, SQLite, JSON).
|
||||
description: Catalog of optional, build-time selectable extensions for the Fun VM (e.g., cURL, SQLite, JSON).
|
||||
permalink: /documentation/extensions/
|
||||
lang: en
|
||||
tags:
|
||||
- area
|
||||
|
|
@ -18,7 +18,7 @@ tags:
|
|||
- examples
|
||||
- extension
|
||||
- extensions
|
||||
- external
|
||||
- extensions
|
||||
- integrations
|
||||
- optional
|
||||
- required
|
||||
|
|
@ -7,7 +7,7 @@ noDate: false
|
|||
title: Fun - INI (iniparser) extension (optional)
|
||||
subtitle: Documentation for INI (iniparser) extension (optional)
|
||||
description: Documentation for INI (iniparser) extension (optional)
|
||||
permalink: /documentation/external/ini/
|
||||
permalink: /documentation/extensions/ini/
|
||||
lang: en
|
||||
tags:
|
||||
- extension
|
||||
|
|
@ -7,7 +7,7 @@ noDate: false
|
|||
title: Fun - JSON (json-c) extension (optional)
|
||||
subtitle: Documentation for JSON (json-c) extension (optional)
|
||||
description: Documentation for JSON (json-c) extension (optional)
|
||||
permalink: /documentation/external/json/
|
||||
permalink: /documentation/extensions/json/
|
||||
lang: en
|
||||
tags:
|
||||
- extension
|
||||
|
|
@ -7,7 +7,7 @@ noDate: false
|
|||
title: Fun - OpenSSL extension (optional)
|
||||
subtitle: Documentation for OpenSSL extension (optional)
|
||||
description: Documentation for OpenSSL extension (optional)
|
||||
permalink: /documentation/external/openssl/
|
||||
permalink: /documentation/extensions/openssl/
|
||||
lang: en
|
||||
tags:
|
||||
- extension
|
||||
|
|
@ -7,7 +7,7 @@ noDate: false
|
|||
title: Fun - PCRE2 (Perl-Compatible Regex) extension (optional)
|
||||
subtitle: Documentation for PCRE2 (Perl-Compatible Regex) extension (optional)
|
||||
description: Documentation for PCRE2 (Perl-Compatible Regex) extension (optional)
|
||||
permalink: /documentation/external/pcre2/
|
||||
permalink: /documentation/extensions/pcre2/
|
||||
lang: en
|
||||
tags:
|
||||
- compatible
|
||||
|
|
@ -7,7 +7,7 @@ noDate: false
|
|||
title: Fun - PC/SC (smart cards) extension (optional)
|
||||
subtitle: Documentation for PC/SC (smart cards) extension (optional)
|
||||
description: Documentation for PC/SC (smart cards) extension (optional)
|
||||
permalink: /documentation/external/pcsc/
|
||||
permalink: /documentation/extensions/pcsc/
|
||||
lang: en
|
||||
tags:
|
||||
- cards
|
||||
|
|
@ -7,7 +7,7 @@ noDate: false
|
|||
title: Fun - SQLite extension (optional)
|
||||
subtitle: Documentation for SQLite extension (optional)
|
||||
description: Documentation for SQLite extension (optional)
|
||||
permalink: /documentation/external/sqlite/
|
||||
permalink: /documentation/extensions/sqlite/
|
||||
lang: en
|
||||
tags:
|
||||
- extension
|
||||
|
|
@ -7,7 +7,7 @@ noDate: false
|
|||
title: Fun - XML (libxml2) extension (optional)
|
||||
subtitle: Documentation for XML (libxml2) extension (optional)
|
||||
description: Documentation for XML (libxml2) extension (optional)
|
||||
permalink: /documentation/external/xml2/
|
||||
permalink: /documentation/extensions/xml2/
|
||||
lang: en
|
||||
tags:
|
||||
- extension
|
||||
|
|
@ -111,7 +111,7 @@ Opcode handlers organization:
|
|||
|
||||
- To keep vm.c readable, most opcode implementations are factored into small .c files included directly into vm.c (e.g., vm/core/load_const.c, vm/logic/and.c, vm/arrays/push.c, vm/math/abs.c, vm/os/thread_spawn.c, etc.).
|
||||
- This is a deliberate “amalgamation” style: small single-purpose C units compiled as part of vm.c.
|
||||
- Optional subsystems (JSON, PCRE2, CURL, SQLite, libSQL, PC/SC, XML2, Tcl/Tk, Notcurses, INI, OpenSSL/LibreSSL crypto helpers, sockets, serial, OS helpers) are grouped under src/external and src/vm/<domain>/.
|
||||
- Optional subsystems (JSON, PCRE2, CURL, SQLite, libSQL, PC/SC, XML2, Tcl/Tk, Notcurses, INI, OpenSSL/LibreSSL crypto helpers, sockets, serial, OS helpers) are grouped under src/extensions and src/vm/<domain>/.
|
||||
|
||||
Dispatch naming and visibility:
|
||||
|
||||
|
|
@ -152,7 +152,7 @@ The VM is dynamically typed. Values carry a tag; operations check types at runti
|
|||
- Maps: OP_MAKE_MAP/KEYS/VALUES/HAS_KEY.
|
||||
- Conversions/reflection: OP_TO_NUMBER/TO_STRING/CAST/TYPEOF, OP_UCLAMP/SCLAMP.
|
||||
- I/O and OS: OP_READ_FILE/WRITE_FILE/INPUT_LINE/ENV/PROC_RUN/PROC_SYSTEM/TIME_NOW_MS/CLOCK_MONO_MS/DATE_FORMAT/OS_LIST_DIR/RANDOM_NUMBER, sockets, serial.
|
||||
- External integrations (optional): JSON, CURL, SQLite, libSQL, PC/SC, XML2, Tcl/Tk, Notcurses, INI, OpenSSL/LibreSSL.
|
||||
- Extensions (optional): JSON, CURL, SQLite, libSQL, PC/SC, XML2, Tcl/Tk, Notcurses, INI, OpenSSL/LibreSSL.
|
||||
|
||||
Each handler enforces argument types and returns clear error messages via vm_raise_error on misuse.
|
||||
|
||||
|
|
@ -257,7 +257,7 @@ The VM includes small, standalone C files for each feature group under src/vm/
|
|||
- Collections and strings: src/vm/arrays/*.c, src/vm/maps/*.c, src/vm/strings/*.c
|
||||
- Conversions/reflection: src/vm/*.c (to_number, to_string, cast, typeof, uclamp, sclamp)
|
||||
- OS and I/O: src/vm/io/*.c, src/vm/os/*.c, sockets and serial
|
||||
- External integrations: src/external/*.c glue with opcode handlers in src/vm/<domain> when enabled by CMake options
|
||||
- Extensions: src/extensions/*.c glue with opcode handlers in src/vm/<domain> when enabled by CMake options
|
||||
|
||||
Feature flags (CMake):
|
||||
|
||||
|
|
@ -297,7 +297,7 @@ From vm.h defaults (tuned for simplicity; adjust if needed):
|
|||
- src/bytecode.h — instruction set and bytecode container
|
||||
- src/parser.c — compiler, expression/statement/block parsing, emission, indentation handling
|
||||
- src/vm/* — small focused opcode handlers by domain
|
||||
- src/external/* — integration shims for optional dependencies
|
||||
- src/extensions/* — integration shims for optional dependencies
|
||||
|
||||
## Concurrency, isolates, and garbage collection
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue