extern generics classes fix, documentation on extern classes updated

This commit is contained in:
sergeych committed 2026-03-15 04:32:06 +03:00
1 parent 74eb8ff082
commit 8e0442670d
10 files changed
+28 -58

No files matched your search

+5 -5
View File
@@ -245,7 +245,7 @@ This keeps Lyng semantics (visibility, overrides, type checks) in Lyng, while Ko
Pure extern declarations use the simplified rule set:
- `extern class` / `extern object` are declaration-only ABI surfaces.
- Every member in their body must be explicitly marked `extern`.
- Every member in their body is implicitly extern (you may still write `extern`, but it is redundant).
- Plain Lyng member implementations inside `extern class` / `extern object` are not allowed.
- Put Lyng behavior into regular classes or extension methods.
@@ -257,14 +257,14 @@ class Counter {
}
```
Note: members must be marked `extern` so the compiler emits the ABI slots that Kotlin bindings attach to. This applies to functions and properties bound via `addFun` / `addVal` / `addVar`.
Note: members of `extern class` / `extern object` are treated as extern by default, so the compiler emits ABI slots that Kotlin bindings attach to. This applies to functions and properties bound via `addFun` / `addVal` / `addVar`.
Example of pure extern class declaration:
```lyng
extern class HostCounter {
extern var value: Int
extern fun inc(by: Int): Int
var value: Int
fun inc(by: Int): Int
}
```
@@ -342,7 +342,7 @@ Notes:
- Required order: declare/eval Lyng object in the module first, then call `bindObject(...)`.
This is the pattern covered by `BridgeBindingTest.testExternObjectBinding`.
- Members must be marked `extern` so the compiler emits ABI slots for Kotlin bindings.
- Members must be extern (explicitly, or implicitly via `extern object`) so the compiler emits ABI slots for Kotlin bindings.
- You can also bind by name/module via `LyngObjectBridge.bind(...)`.
Minimal `extern fun` example:
+2 -2
View File
@@ -248,7 +248,7 @@ The `Obj.getLyngExceptionMessageWithStackTrace()` extension method has been adde
Lyng now provides a public Kotlin reflection bridge and a Lyng‑first class binding workflow. This is the **preferred** way to write Kotlin extensions and library integrations:
- **Bridge resolver**: explicit handles for values, vars, and callables with predictable lookup rules.
- **Class bridge binding**: declare classes/members in Lyng (marked `extern`) and bind the implementations in Kotlin before the first instance is created.
- **Extern declaration rule**: `extern class` / `extern object` are declaration-only; all members in their bodies must be explicitly marked `extern`.
- **Class bridge binding**: declare extern surfaces in Lyng (`extern` members, or members inside `extern class/object`) and bind the implementations in Kotlin before the first instance is created.
- **Extern declaration rule**: `extern class` / `extern object` are declaration-only; all members in their bodies are implicitly extern.
See **Embedding Lyng** for full samples and usage details.
+1 -1
View File
@@ -20,7 +20,7 @@ The API is fixed and will be kept with further Lyng core changes. It is now the
Extern declaration clarification:
- `extern class` / `extern object` are pure extern surfaces.
- Members inside them must be explicitly marked `extern`.
- Members inside them are implicitly extern (`extern` on a member is optional/redundant).
- Lyng method/property bodies for these declarations should be implemented as extensions instead.
### Smart types system