ffi 2.6 green: #jni_method_descriptor("(Sig)Ret") override

New `hash_jni_method_descriptor` lexer token + LSP keyword
classification. `JniMethodDecl` gains `desc_override: ?[]const u8`.
parseJniClassDecl accepts an optional `#jni_method_descriptor("...")`
clause between the return type and the terminating `;`, stashing the
literal as the override. Auto-derivation in Phase 2.8 will treat
this as the precedence override when present.

The 2.6 xfail commit (0ed4799) used the working name `#desc` in its
test file; this commit renames to `#jni_method_descriptor` for
parallel naming with the rest of the FFI directive set (`#jni_call`,
`#jni_class`, `#jni_env`, ...). Test snapshot flips xfail → green.

125/125 examples green.
This commit is contained in:
agra
2026-05-20 10:10:23 +03:00
parent 0ed4799f5f
commit 11021d800d
8 changed files with 29 additions and 10 deletions

View File

@@ -1121,6 +1121,20 @@ pub const Parser = struct {
return_type = try self.parseTypeExpr();
}
// Optional `#jni_method_descriptor("(Sig)Ret")` — explicit JNI descriptor override.
var desc_override: ?[]const u8 = null;
if (self.current.tag == .hash_jni_method_descriptor) {
self.advance(); // skip `#jni_method_descriptor`
try self.expect(.l_paren);
if (self.current.tag != .string_literal) {
return self.fail("expected string literal JNI descriptor after '#jni_method_descriptor('");
}
const raw_desc = self.tokenSlice(self.current);
desc_override = raw_desc[1 .. raw_desc.len - 1];
self.advance();
try self.expect(.r_paren);
}
try self.expect(.semicolon);
try members.append(self.allocator, .{ .method = .{
@@ -1129,6 +1143,7 @@ pub const Parser = struct {
.param_names = try param_names.toOwnedSlice(self.allocator),
.return_type = return_type,
.is_static = is_static,
.desc_override = desc_override,
} });
}
try self.expect(.r_brace);