ffi: drop static keyword on foreign-class methods; param type discriminates
`static name :: ...` was redundant — instance methods always declare `self: *Self` as their first param by convention. The parser now derives `is_static` from the first param's TYPE: if it's `*Self` the method is an instance method; anything else (including no params at all) is a class method. Removes a token from the surface, keeps the dispatch behavior identical. The receiver param's NAME doesn't matter — only its type. Calling the first param `this`, `me`, `receiver`, etc. is fine as long as the type is `*Self`. This mirrors how the rest of sx handles receiver dispatch. Migration of every site that used the keyword: - `library/modules/platform/android.sx` — `SurfaceView.new(ctx)`. - `examples/ffi-jni-class-03-static.sx` — `Math.abs(n)`. - `examples/ffi-jni-main-03-ctor.sx` — `SurfaceView.new(ctx)` in the `#jni_main` body. - `examples/ffi-objc-dsl-05-static.sx` — NSObject's `.class()` / `.description()`. 164/164 example tests; chess clean on macOS / iOS sim / Android via `tools/verify-step.sh`.
This commit is contained in:
@@ -501,6 +501,16 @@ plan's notional `::` — avoids a new postfix operator. Test:
|
||||
and `+description` class methods (NSObject is always available at
|
||||
module-load, unlike test classes created in main's body).
|
||||
|
||||
Class-method declarations no longer need an explicit `static` keyword.
|
||||
The parser derives `is_static` from the first param's TYPE: if it's
|
||||
`*Self` the method is an instance method; anything else (including no
|
||||
params at all) is a class method. Surface examples now write
|
||||
`new :: (ctx: *JContext) -> *Self;` instead of
|
||||
`static new :: (...)`. The receiver param NAME doesn't matter — the
|
||||
type is the contract. Updated: `library/modules/platform/android.sx`,
|
||||
`examples/ffi-jni-class-03-static.sx`, `examples/ffi-jni-main-03-ctor.sx`,
|
||||
`examples/ffi-objc-dsl-05-static.sx`.
|
||||
|
||||
Open work, in roughly the order they make sense:
|
||||
- **Phase 3 step 3.2** — `#selector("explicit:")` override + golden
|
||||
test for the default-mangling table. Escape hatch for selectors
|
||||
|
||||
Reference in New Issue
Block a user