From 1dee9ba67bcaecc8ec475156acd34e22c233b81a Mon Sep 17 00:00:00 2001 From: agra Date: Wed, 20 May 2026 10:03:54 +0300 Subject: [PATCH] ffi 2.5 xfail: `name: Type;` field body item in `#jni_class` `Point :: #jni_class("...") { x: s32; y: s32; }` should parse, today's 2.4 body loop sees the identifier `x`, expects `::`, hits `:` and errors. The make-green follow-up adds a `field` variant to `JniClassMember` and a parser branch that detects `:` (vs `::`) as the field-decl indicator. --- examples/ffi-jni-class-05-field.sx | 19 +++++++++++++++++++ tests/expected/ffi-jni-class-05-field.exit | 1 + tests/expected/ffi-jni-class-05-field.txt | 1 + 3 files changed, 21 insertions(+) create mode 100644 examples/ffi-jni-class-05-field.sx create mode 100644 tests/expected/ffi-jni-class-05-field.exit create mode 100644 tests/expected/ffi-jni-class-05-field.txt diff --git a/examples/ffi-jni-class-05-field.sx b/examples/ffi-jni-class-05-field.sx new file mode 100644 index 0000000..46220f8 --- /dev/null +++ b/examples/ffi-jni-class-05-field.sx @@ -0,0 +1,19 @@ +// Phase 2 step 2.5 (PLAN-FFI.md): xfail then green for the field body +// item inside a `#jni_class` declaration. +// +// `name: Type;` declares an instance field backed by JNI's +// `GetField` / `SetField` family at lowering time (2.13). +// Step 2.5 extends `parseJniClassDecl` to recognise the colon between +// name and type as the field-decl indicator (vs the `::` of a method). + +#import "modules/std.sx"; + +Point :: #jni_class("android/graphics/Point") { + x: s32; + y: s32; +} + +main :: () -> s32 { + print("parse-only ok\n"); + 0; +} diff --git a/tests/expected/ffi-jni-class-05-field.exit b/tests/expected/ffi-jni-class-05-field.exit new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/tests/expected/ffi-jni-class-05-field.exit @@ -0,0 +1 @@ +1 diff --git a/tests/expected/ffi-jni-class-05-field.txt b/tests/expected/ffi-jni-class-05-field.txt new file mode 100644 index 0000000..ebca0b9 --- /dev/null +++ b/tests/expected/ffi-jni-class-05-field.txt @@ -0,0 +1 @@ +/Users/agra/projects/sx/examples/ffi-jni-class-05-field.sx:12:6: error: expected '::'