-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathgreet_plugin.pb.go
More file actions
51 lines (42 loc) · 1.14 KB
/
greet_plugin.pb.go
File metadata and controls
51 lines (42 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//go:build tinygo.wasm
// Code generated by protoc-gen-go-plugin. DO NOT EDIT.
// versions:
// protoc-gen-go-plugin v0.1.0
// protoc v3.21.1
// source: examples/helloworld/greeting/greet.proto
package greeting
import (
context "context"
wasm "github.com/knqyf263/go-plugin/wasm"
)
const GreeterPluginAPIVersion = 1
//export greeter_api_version
func _greeter_api_version() uint64 {
return GreeterPluginAPIVersion
}
var greeter Greeter
func RegisterGreeter(p Greeter) {
greeter = p
}
//export greeter_greet
func _greeter_greet(ptr, size uint32) uint64 {
b := wasm.PtrToByte(ptr, size)
req := new(GreetRequest)
if err := req.UnmarshalVT(b); err != nil {
return 0
}
response, err := greeter.Greet(context.Background(), req)
if err != nil {
ptr, size = wasm.ByteToPtr([]byte(err.Error()))
return (uint64(ptr) << uint64(32)) | uint64(size) |
// Indicate that this is the error string by setting the 32-th bit, assuming that
// no data exceeds 31-bit size (2 GiB).
(1 << 31)
}
b, err = response.MarshalVT()
if err != nil {
return 0
}
ptr, size = wasm.ByteToPtr(b)
return (uint64(ptr) << uint64(32)) | uint64(size)
}