Skip to content

Initial commit#1

Open
Nyuke235 wants to merge 15 commits into
MobilityDB:mainfrom
Nyuke235:main
Open

Initial commit#1
Nyuke235 wants to merge 15 commits into
MobilityDB:mainfrom
Nyuke235:main

Conversation

@Nyuke235
Copy link
Copy Markdown
Collaborator

  • Compilation with a multi-stage Dockerfile of MEOS and all its dependencies in wasm64 or wasm32 (both have been tested and work), with automatic detection of pointer mode at runtime.
  • FunctionsGenerator.ts that reads meos-idl.json and automatically generates two files:
    • bindings.c: C wrappers EMSCRIPTEN_KEEPALIVE
    • functions.ts: TypeScript bindings calling C functions
  • Implemented types (each type exposes constructors, accessors, predicates, set operations, and comparisons):
    • Number: IntSpan, FloatSpan, IntSpanSet, FloatSpanSet, IntSet, FloatSet
    • Time: TsTzSpan, TsTzSpanSet, TsTzSet, DateSpan, DateSpanSet, DateSet
    • Boxes: TBox
    • Temporal: TBool, TInt, TFloat
  • Reorganization of source code into subfolders
  • All tests for most types
  • Updated README with more details (installation, memory management, types)

Nyuke235 added 15 commits April 29, 2026 16:06
- dateset
- datespanset
- floatset
- floatspanset
- intset
- intspanset
- base class: MeosException
- internal errors
- argument errors
- I/O errors
- renamed MeoSet -> MeosSet
- drop wasm32: MEOS.js now targets wasm64 exclusively; added assertWasm64Supported() which validates a 13-byte MEMORY64 probe binary via WebAssembly.validate() before loading the module
- renamed src/core/functions.ts -> core/functions/functions.generated.ts
- moved codegen/ and core/ to project root (src/ removed)
- mirrored core/ structure in test/ (test/types/, test/functions/)
- added typed MEOS error handling: full exception hierarchy in errors.ts
- added error handling guide in docs/guide/errors.md
- updated README, tsconfig, typedoc, Dockerfile and all import paths
Temporal subtype classes
- TBoolInst, TBoolSeq, TBoolSeqSet
- TIntInst, TIntSeq, TIntSeqSet
- TFloatInst, TFloatSeq, TFloatSeqSet
- TemporalFactory: createTBool, createTInt, createTFloat via temporal_subtype()
- wasm/meos.d.ts: expose allocate / ALLOC_NORMAL
Test coverage:
- test/types/temporal/test_subtypes: 25 tests for all subtypes constructors & factory routing
- test_tbool
- test_tint
- test_tfloat
- test_tbox
Docker / build:
Dockerfile: GSL URL ftp->ftpmirror, config.sub via automake, pin MobilityDB commit (ARG MOBILITYDB_COMMIT=ee27da1), drop --depth=1
Restructuration:
- core/types/base/* -> basic/tbool/, baisc/tint/, basic/tfloat/
- core/types/base/{Span, SpanSet, MeosSet} -> collections/base/
- core/types/number/* -> collections/number/
- core/types/time/* -> collections/time/
TText (core/types/basic/ttext/):
- TText.ts
- TTextInst.ts
- TTextSeq.ts
- TTextSeqSet.ts
- TemporalFactory
- 35 tests for TText
…odegen:

New types (collections/number):
- BigIntSpan
- BigIntSpanSet
- BigIntSet
New type (collections/text):
- TextSet
Generator fix (FunctionsGenerator.ts):
- Add isInt64() predicate
- Return values wrapped with Number(), arguments with BigInt()
- Fix boolResult path for int64 result types
- Fixes BigInt WASM calls that were silently returning bigint instead of number, and shift_scale calls crashing with 'Cannot convert N to a BigInt'
Bugs fixed:
- isInt64 predicate was not used inside detectBoolResult
Compile errors:
- TextSet.ts -> distance() was abstract but unimplemented
@estebanzimanyi
Copy link
Copy Markdown
Member

Cross-binding parity status (2026-05-21) — IDL refresh path verified, type-wrapper sweep needed

After running the codegen locally against the MEOS-API published meos-idl.json (the canonical SoT every other FFI binding now consumes — see PyMEOS-CFFI #18/#19, GoMEOS #2/#3, MEOS.NET #3/#4, JMEOS #19):

cp /path/to/MEOS-API/output/meos-idl.json codegen/res/meos-idl.json
npm run generate
# Done. Generated: 2663  Skipped: 1  Manual: 35  Duplicates: 0

Result:

  • core/functions/functions.generated.ts — 2 663 generated functions (up from 1 685)
  • core/c-src/bindings.c — same 2 663 EMSCRIPTEN_KEEPALIVE wrappers
  • Extended-type surface now present: 244 tcbuffer, 118 tnpoint, 108 tpose, 136 trgeo mentions

However, npx tsc --noEmit surfaces 234 type errors in the existing high-level type wrappers (core/types/basic/*, core/types/collections/*, core/types/temporal/*). The errors are dominated by:

  • boolean → number coercions: MEOS-API's canonical IDL normalizes the bool-returning predicates as int (matching how the C FFI surfaces them via libclang). The type wrappers were authored against the old IDL where these were typed as bool.
  • Arity changes: a few functions now take a context/state parameter (3 args, not 2).
  • Return-type changes: number where the old wrappers expected string.

These are not regressions — they're signature corrections that flow from the same MEOS-API canonical normalization powering the other 4 FFI bindings.

Path forward for a clean PR:

  1. Refresh codegen/res/meos-idl.json with MEOS-API's published version
  2. npm run generate to regenerate both outputs
  3. Sweep core/types/**/*.ts to adopt the new signatures (~234 sites; mostly mechanical !== 0 for the boolean→int cases)
  4. npx tsc --noEmit clean

I've verified steps 1+2 locally on a fork branch (estebanzimanyi:feat/meos-idl-refresh-extended-types) but haven't shipped the partial PR — step 3 is the substantial work and best left as part of one cohesive update. Happy to either:

  • a) author the full sweep in a fork-stacked PR after this PR's review settles, or
  • b) point at this comment as the recipe for whoever takes the next pass.

@Nyuke235
Copy link
Copy Markdown
Collaborator Author

Thank you a lot for digging into the regen end-to-end and laying out the failure mode this clearly.

Let's go with option (a). I'd like to keep the current PR focused on its existing scope rather than bundle the IDL refresh in (the 234-site sweep is mechanical but large enough to muddy this diff), so once this PR is merged, please go ahead and open the fork-stacked PR from estebanzimanyi:feat/meos-idl-refresh-extended-types with:

  1. codegen/res/meos-idl.json refreshed against MEOS-API's published version
  2. The regenerated core/functions/functions.generated.ts and core/c-src/bindings.c committed
  3. The core/types/**/*.ts sweep, ideally in one cohesive commit since most sites are the same pattern
  4. npx tsc --noEmit clean as the acceptance criterion

I'll prioritize reviewing it as soon as it's up. Aligning on MEOS-API's canonical IDL is clearly the right move

Thank you again.

@estebanzimanyi
Copy link
Copy Markdown
Member

Opened as #2 (estebanzimanyi:feat/meos-idl-refresh-extended-types), stacked on this PR so it's ready to review now and its diff narrows to just the refresh once this merges.

Walking your list: 1 (IDL refreshed to MEOS-API canonical), 2 (regenerated functions.generated.ts + bindings.c, 1679 → 2794 functions incl. the tcbuffer/tnpoint/tpose/trgeometry surface), and 4 (npx tsc --noEmit clean) are all in.

3 — the core/types/** sweep — turned out to be unnecessary, and it's worth flagging why. The type errors I reported earlier weren't wrapper drift; they traced to an upstream IDL regression: the MEOS-API libclang parse left the PG text (varlena) type undeclared, so the implicit-int rule collapsed every text * to int * across 88 functions. That defeated the generator's text* detection — the bit that injects cstring2text/text2cstring so text* surfaces as a plain JS string — so those signatures degraded to opaque Ptr and the wrappers stopped matching.

Fixed at the root in MobilityDB/MEOS-API#15 (recovers PG types collapsed to int, now including text / const text * / text **, plus the bool*/TimestampTz*/int64* pointer-returns it previously missed). Against the corrected IDL, the refresh regenerates with zero core/types edits and a clean tsc — so #2 is a pure regen, no hand-written sweep to review. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants