-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wit, wit/bindgen: correctly generate linker names for world-level fun…
…ctions and interfaces (#176) * testdata/issues: add test case for #175 * wit/bindgen: propagate TypeOwner (World or Interface) * wit/bindgen: rename funcDecl fields * wit/bindgen: embed original wit.Function, Direction, and owner in funcDecl * wit/bindgen: use pointer to funcDecl * wit/bindgen: use embedded fields in funcDecl * wit/bindgen: constrain defined list to wit.Node * wit/bindgen: use pointers to typeDecl * wit, wit/bindgen: WITPackage() method * wit/bindgen: correctly generate linker prefix for world-scoped functions Fixes #175. * testdata/issues: add world-scoped imported function that forces $root module * wit/bindgen: start to scope Go packages by WorldItem, not Ident * wit/bindgen: detect $root module name * wit/bindgen: split out method newPackage * wit/bindgen: remove calls to ownerIdent * wit/bindgen: remove interfaceIDs map * wit: update tests for interfaces with nil names * wit: remove unused Indent methods * wit, wit/bindgen: remove InterfaceName method, prepopulate generator.moduleNames map * wit/bindgen: remove wit/bindgen prefix from generated Go packages in tests * wit/bindgen: detect and return error from defineWorld * wit/bindgen: correctly generate interfaces from other packages * CHANGELOG: add link to #175
- Loading branch information
Showing
9 changed files
with
457 additions
and
244 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package issues:issue175; | ||
|
||
world w { | ||
export example: interface { | ||
f1: func() -> s32; | ||
resource r { | ||
constructor(a: f64); | ||
get-a: func() -> f64; | ||
set-a: func(a: f64); | ||
add: static func(r: r, a: f64) -> r; | ||
} | ||
} | ||
import f2: func() -> f32; | ||
export f3: func() -> s64; | ||
} |
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,170 @@ | ||
{ | ||
"worlds": [ | ||
{ | ||
"name": "w", | ||
"imports": { | ||
"f2": { | ||
"function": { | ||
"name": "f2", | ||
"kind": "freestanding", | ||
"params": [], | ||
"results": [ | ||
{ | ||
"type": "f32" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"exports": { | ||
"f3": { | ||
"function": { | ||
"name": "f3", | ||
"kind": "freestanding", | ||
"params": [], | ||
"results": [ | ||
{ | ||
"type": "s64" | ||
} | ||
] | ||
} | ||
}, | ||
"example": { | ||
"interface": { | ||
"id": 0 | ||
} | ||
} | ||
}, | ||
"package": 0 | ||
} | ||
], | ||
"interfaces": [ | ||
{ | ||
"name": null, | ||
"types": { | ||
"r": 0 | ||
}, | ||
"functions": { | ||
"f1": { | ||
"name": "f1", | ||
"kind": "freestanding", | ||
"params": [], | ||
"results": [ | ||
{ | ||
"type": "s32" | ||
} | ||
] | ||
}, | ||
"[constructor]r": { | ||
"name": "[constructor]r", | ||
"kind": { | ||
"constructor": 0 | ||
}, | ||
"params": [ | ||
{ | ||
"name": "a", | ||
"type": "f64" | ||
} | ||
], | ||
"results": [ | ||
{ | ||
"type": 2 | ||
} | ||
] | ||
}, | ||
"[method]r.get-a": { | ||
"name": "[method]r.get-a", | ||
"kind": { | ||
"method": 0 | ||
}, | ||
"params": [ | ||
{ | ||
"name": "self", | ||
"type": 1 | ||
} | ||
], | ||
"results": [ | ||
{ | ||
"type": "f64" | ||
} | ||
] | ||
}, | ||
"[method]r.set-a": { | ||
"name": "[method]r.set-a", | ||
"kind": { | ||
"method": 0 | ||
}, | ||
"params": [ | ||
{ | ||
"name": "self", | ||
"type": 1 | ||
}, | ||
{ | ||
"name": "a", | ||
"type": "f64" | ||
} | ||
], | ||
"results": [] | ||
}, | ||
"[static]r.add": { | ||
"name": "[static]r.add", | ||
"kind": { | ||
"static": 0 | ||
}, | ||
"params": [ | ||
{ | ||
"name": "r", | ||
"type": 2 | ||
}, | ||
{ | ||
"name": "a", | ||
"type": "f64" | ||
} | ||
], | ||
"results": [ | ||
{ | ||
"type": 2 | ||
} | ||
] | ||
} | ||
}, | ||
"package": 0 | ||
} | ||
], | ||
"types": [ | ||
{ | ||
"name": "r", | ||
"kind": "resource", | ||
"owner": { | ||
"interface": 0 | ||
} | ||
}, | ||
{ | ||
"name": null, | ||
"kind": { | ||
"handle": { | ||
"borrow": 0 | ||
} | ||
}, | ||
"owner": null | ||
}, | ||
{ | ||
"name": null, | ||
"kind": { | ||
"handle": { | ||
"own": 0 | ||
} | ||
}, | ||
"owner": null | ||
} | ||
], | ||
"packages": [ | ||
{ | ||
"name": "issues:issue175", | ||
"interfaces": {}, | ||
"worlds": { | ||
"w": 0 | ||
} | ||
} | ||
] | ||
} |
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,15 @@ | ||
package issues:issue175; | ||
|
||
world w { | ||
import f2: func() -> f32; | ||
export f3: func() -> s64; | ||
export example: interface { | ||
resource r { | ||
constructor(a: f64); | ||
get-a: func() -> f64; | ||
set-a: func(a: f64); | ||
add: static func(r: r, a: f64) -> r; | ||
} | ||
f1: func() -> s32; | ||
} | ||
} |
Oops, something went wrong.