Debian Codegraph @

examples/ext/README.md

raw symbols SCIP
1 # ext
2
3 Demonstrates how to use external types in an `avo` function signature.
4
5 In this case, you will need to write the function stub yourself.
6
7 [embedmd]:# (stub.go /package/ $)
8 ```go
9 package ext
10
11 import "github.com/mmcloughlin/avo/examples/ext/ext"
12
13 // StructFieldB returns field B.
14 func StructFieldB(e ext.Struct) byte
15 ```
16
17 Then in place of the usual `TEXT` declaration we use `Implement` to state that we are beginning the definition of a function already declared in the package stub file.
18
19 [embedmd]:# (asm.go go /.*Package.*/ /RET.*/)
20 ```go
21 Package("github.com/mmcloughlin/avo/examples/ext")
22 Implement("StructFieldB")
23 b := Load(Param("e").Field("B"), GP8())
24 Store(b, ReturnIndex(0))
25 RET()
26 ```
27
28 Finally, in this case the `go:generate` line is different since we do not need to generate the stub file.
29
30 [embedmd]:# (ext_test.go go /.*go:generate.*/)
31 ```go
32 //go:generate go run asm.go -out ext.s
33 ```