Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
# docker build --output type=local,dest=./wasm --target wasm .
#
# Versions:
# emsdk 5.0.6 | MobilityDB ee27da1 | GEOS 3.14.1
# emsdk 5.0.6 | MobilityDB 2c4243a | GEOS 3.14.1
# PROJ 9.8.1 | SQLite 3.46.1 | JSON-C 0.18 | GSL 2.8

# Pinned MobilityDB commit — update together with meos-idl.json when upgrading.
ARG MOBILITYDB_COMMIT=ee27da1a6d2f6cdbdd226bd66a1e7fea86c2832b
ARG MOBILITYDB_COMMIT=2c4243a2656fcef27fa0a2557234593e3e9b125b

# EMSCRIPTEN & EVERY NEEDED TOOL
FROM emscripten/emsdk:5.0.6 AS base
Expand Down
21 changes: 21 additions & 0 deletions codegen/FunctionsGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,19 @@ const isRawBytes = (t: string) => {
*/
const isInterval = (t: string) => clean(t) === 'Interval';

/**
* True for the PostgreSQL Datum tagged value in any pointer arity
* (Datum, Datum *, const Datum, ...). A Datum is an opaque uintptr_t whose
* interpretation depends on the runtime base type: for Float8 / text / geometry
* it holds a *pointer*, not the value (and is only 32-bit under WASM32), so it
* can never be marshalled safely to a JS scalar. Datum only ever appears on
* INTERNAL functions (meos_internal.h); the user-facing API is the typed
* *_meos.c wrappers declared in the public headers, e.g.
* temporal_start_value(Datum, internal) -> tint_start_value / tfloat_start_value / ttext_start_value
* Functions whose signature mentions Datum are therefore skipped entirely.
*/
const isDatum = (t: string) => /\bDatum\b/.test(clean(t));

/**
* True for the PostgreSQL text type passed as a single pointer (text *).
* These require cstring2text / text2cstring conversion in the C wrapper
Expand Down Expand Up @@ -352,6 +365,10 @@ function detectBoolResult(fn: IdlFunction): BoolResultInfo | null {
*
* The only cases that remain un-generatable are:
*
* - Datum return or param: Datum is an opaque, internal-only tagged value
* (see isDatum) that cannot be marshalled to a JS scalar. It appears only
* on internal functions; the user-facing API is the typed *_meos.c wrapper.
*
* - Function-pointer params: Emscripten cannot marshal C function pointers
* automatically. These require hand-written wrappers using
* Module.addFunction() and are listed in MANUAL_FUNCTIONS if needed.
Expand All @@ -361,7 +378,11 @@ function detectBoolResult(fn: IdlFunction): BoolResultInfo | null {
* handled normally as Ptr.
*/
function shouldSkip(fn: IdlFunction): string | null {
if (isDatum(fn.returnType.c))
return 'internal Datum return — use the typed *_meos.c wrapper';
for (const p of fn.params) {
if (isDatum(p.cType))
return `internal Datum param '${p.name}' — use the typed *_meos.c wrapper`;
if (isFuncPtr(p.cType)) return `function-pointer param '${p.name}'`;
if (isInterval(p.cType)) return `Interval by-value param '${p.name}'`;
}
Expand Down
Loading