-
Notifications
You must be signed in to change notification settings - Fork 287
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/core/runtime: new attribute name for extern
Right now, we only allow one type of extern attribute in a file. At the file level, we define @extern(kind). Fields within the file can then be associated with an @extern attribute that is interpreted as defined by kind. This approach may work for lower-level functionality like support for WASM, but it seems a bit unintuitive for embed. Instead, we suggest that after a file-level @extern(kind) declaration the field attributes take the form @kind(). This is what is implemented here. This has the additional benefit that we could more easily allow different types of extern fields within a single file. Note that the original reason to reuse @extern for field attributes was to avoid a proliferation of attributes. This namespace encrouching is still a bit mitigated by the @extern(kind) attribute. In the future we can find a different mechanism to define attributes scoped by domain. Issue #2031 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: I28b1fdd0f0a85c46a544f71bbff40a7772e60873 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1196717 Reviewed-by: Daniel Martí <[email protected]> Unity-Result: CUE porcuepine <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
- Loading branch information
Showing
8 changed files
with
59 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
package failinit | ||
|
||
|
||
foo: _ @extern("file.xx") | ||
foo: _ @test("file.xx") | ||
|
||
-- out/extern -- | ||
TEST: fail initialization |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
-- cue.mod/modules.cue -- | ||
-- file1.cue -- | ||
@extern("test") | ||
|
||
package foo | ||
|
||
|
||
Foo: _ @extern(file1.xx, abi=c, sig="func(int)int") | ||
|
||
Rename: _ @extern(file1.xx, name=Emaner, abi=c, sig="func(int)int") | ||
|
||
-- file2.cue -- | ||
@extern("test") | ||
|
||
package foo | ||
|
||
|
||
Bar: { | ||
@other() | ||
@extern(file2.xx, abi=c, sig="func(int)int") | ||
_ | ||
} | ||
|
||
-- extern/out -- | ||
-- out/extern -- | ||
{ | ||
Foo: implFoo1 | ||
Bar: implBar2 | ||
Rename: implEmaner1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters