Skip to content
Snippets Groups Projects
Commit 5f76f7d8 authored by Martin Stiemerling's avatar Martin Stiemerling
Browse files

Working SBILoader with Interface, but not correct interface yet

parent bc777bcc
No related branches found
No related tags found
1 merge request!75Draft: Resolve "Create interfaces for internal data structure"
Pipeline #54690 passed with warnings
......@@ -6,11 +6,12 @@ import (
"plugin"
)
type SBIGreeter interface {
SBIHello()
type SBIInterface interface {
Hello() string
AddClient()
}
func SBILoader () {
func SBILoader () error {
modPath := "/Users/mls/go/src/code.fbi.h-da.de/cocsn/byowsbi/byowsbi.o"
// open the so file that contains the SBI-plugin as step before loading the symbols
......@@ -21,21 +22,23 @@ func SBILoader () {
}
// loading the symbols
sbiModule, err := plug.Lookup("SBIGreeter")
sbiModule, err := plug.Lookup("SBIInterface")
if err != nil {
fmt.Println(err)
os.Exit(1)
}
// Assert the loaded symbol
var sbigreeter SBIGreeter
sbigreeter, ok := sbiModule.(SBIGreeter)
var sbi SBIInterface
sbi, ok := sbiModule.(SBIInterface)
if !ok {
fmt.Println("unexpected type from module symbol")
fmt.Println(ok)
os.Exit(1)
}
// use me!
sbigreeter.SBIHello()
fmt.Print(sbi.Hello())
sbi.AddClient()
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment