From e225adbd1c9a696657d4e990903b09640ef33c89 Mon Sep 17 00:00:00 2001 From: agra Date: Wed, 20 May 2026 09:36:20 +0300 Subject: [PATCH] ffi 2.4 xfail: `#extends Alias;` body item in `#jni_class` `Window :: #jni_class("...") { #extends View; ... }` should parse, today's 2.3 parser doesn't recognise `#extends` as a token and the body loop reports "expected method name". The make-green follow-up adds `hash_extends`/`hash_implements` lexer tokens, refactors `JniClassDecl.methods` into a `members` tagged union, and dispatches in the body loop on the leading token. --- examples/ffi-jni-class-04-extends.sx | 25 ++++++++++++++++++++ tests/expected/ffi-jni-class-04-extends.exit | 1 + tests/expected/ffi-jni-class-04-extends.txt | 1 + 3 files changed, 27 insertions(+) create mode 100644 examples/ffi-jni-class-04-extends.sx create mode 100644 tests/expected/ffi-jni-class-04-extends.exit create mode 100644 tests/expected/ffi-jni-class-04-extends.txt diff --git a/examples/ffi-jni-class-04-extends.sx b/examples/ffi-jni-class-04-extends.sx new file mode 100644 index 0000000..d112f68 --- /dev/null +++ b/examples/ffi-jni-class-04-extends.sx @@ -0,0 +1,25 @@ +// Phase 2 step 2.4 (PLAN-FFI.md): xfail then green for the `#extends` +// and `#implements` body items inside a `#jni_class` declaration. +// +// `#extends Alias;` declares a single-inheritance superclass reference +// using the sx-side alias name (not the foreign Java path — that lives +// in the alias's own `#jni_class(...)` directive arg). `#implements +// Alias;` is repeatable and records interface conformance. +// +// Step 2.4 introduces `hash_extends` and `hash_implements` tokens and +// refactors `JniClassDecl.methods` into a `members` tagged union that +// holds method/extends/implements variants. + +#import "modules/std.sx"; + +View :: #jni_class("android/view/View") { } + +Window :: #jni_class("android/view/Window") { + #extends View; + getDecorView :: (self: *Self) -> *View; +} + +main :: () -> s32 { + print("parse-only ok\n"); + 0; +} diff --git a/tests/expected/ffi-jni-class-04-extends.exit b/tests/expected/ffi-jni-class-04-extends.exit new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/tests/expected/ffi-jni-class-04-extends.exit @@ -0,0 +1 @@ +1 diff --git a/tests/expected/ffi-jni-class-04-extends.txt b/tests/expected/ffi-jni-class-04-extends.txt new file mode 100644 index 0000000..f830242 --- /dev/null +++ b/tests/expected/ffi-jni-class-04-extends.txt @@ -0,0 +1 @@ +/Users/agra/projects/sx/examples/ffi-jni-class-04-extends.sx:18:5: error: expected method name in '#jni_class' body